/* Observatorio de Turismo — panel de administración */
:root {
  --brand: #2f6b3a; --brand-d: #24532d; --brand-2: #8a5a2b;
  --page: #f4f3ee; --surface: #fff; --ink: #18201a; --ink-2: #545b54; --muted: #8a8f88;
  --line: #e2dfd5; --soft: #f7f6f1; --danger: #b83232; --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 14.5px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.muted { color: var(--ink-2); font-size: 13px; }
.center { text-align: center; }
code { background: #eeece4; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; overflow-wrap: anywhere; }

/* ---------- Botones y formularios ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-weight: 700; font-size: 13.5px; padding: 8px 16px; border-radius: 9px; cursor: pointer; text-decoration: none; white-space: nowrap; min-height: 38px; }
.btn:hover { background: var(--brand-d); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--soft); }
.btn-danger { background: #fff; color: var(--danger); border-color: #e9c3c3; }
.btn-danger:hover { background: #fbeeee; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; min-height: 32px; }
.btn-block { width: 100%; }
form.inline { display: inline; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label.check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 500; }
label.check input { margin-top: 3px; }
input, select, textarea { font: inherit; font-size: 14px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 38px; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--brand); }
input[type=color] { padding: 2px; height: 38px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid h3 { font-size: 14px; margin-top: 6px; color: var(--ink); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hint { font-weight: 400; font-size: 12px; color: var(--muted); }

.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 13.5px; border: 1px solid; }
.alert-ok { background: #e8f4ea; border-color: #bfe0c6; color: #1d5a2a; }
.alert-error { background: #fbeaea; border-color: #f0c4c4; color: #8c1f1f; }
.alert-warn { background: #fff5dc; border-color: #f2dda2; color: #6b4a00; }
.alert-info { background: #e8f0fb; border-color: #c4d7f2; color: #1d4f91; }

/* ---------- Login / instalador ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(900px 400px at 20% 0%, #dfe9da, transparent), var(--page); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 30px; box-shadow: 0 10px 40px rgba(30,40,30,.08); }
.auth-card h1 { font-size: 22px; margin: 8px 0 4px; }
.auth-card .stack { margin-top: 18px; }
.auth-brand { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--brand); }
.auth-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--brand); box-shadow: 14px 0 0 var(--brand-2); margin-right: 14px; }
.auth-logo { width: 64px; height: 64px; object-fit: contain; display: block; margin-bottom: 10px; }

/* ---------- Estructura ---------- */
.admin { display: flex; min-height: 100vh; }
.sidebar { width: 250px; flex: none; background: #1c2a1f; color: #d9e2d6; padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sb-brand { display: flex; gap: 10px; align-items: center; color: #fff; text-decoration: none; padding: 4px 6px 16px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 8px; }
.sb-brand img { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; }
.sb-brand small { display: block; font-size: 11.5px; color: #9fb09a; }
.sb-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: #7f927b; margin: 14px 8px 6px; font-weight: 700; }
.sb-link { display: flex; align-items: center; gap: 10px; color: #d9e2d6; text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; font-weight: 500; }
.sb-link svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.sb-link:hover { background: rgba(255,255,255,.06); }
.sb-link.active { background: var(--brand); color: #fff; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1001; }
.topbar h1 { font-size: 18px; flex: 1; min-width: 0; }
.tb-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tb-user { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.mun-switch select { min-height: 32px; padding: 4px 8px; font-size: 13px; }
.burger { display: none; font-size: 22px; cursor: pointer; padding: 0 4px; color: var(--ink); flex-direction: row; }
.sb-backdrop { display: none; }
.content { padding: 22px 24px 40px; max-width: 1400px; width: 100%; }

/* ---------- Tarjetas y tablas ---------- */
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2 { font-size: 16px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.cols-3-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { background: var(--soft); text-align: left; padding: 9px 12px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); white-space: nowrap; }
.tbl td { padding: 8px 12px; border-top: 1px solid #eeece5; vertical-align: middle; }
.tbl tr:hover td { background: #fbfaf6; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .acts { white-space: nowrap; text-align: right; }
.tbl.grid-input td { padding: 4px 6px; }
.tbl.grid-input input { min-height: 34px; padding: 5px 8px; font-size: 13.5px; text-align: right; font-variant-numeric: tabular-nums; }
.tbl.grid-input input.txt { text-align: left; }
.tbl.grid-input th.mes, .tbl.grid-input td.mes { position: sticky; left: 0; background: #fff; z-index: 1; font-weight: 700; }
.tbl.grid-input th.mes { background: var(--soft); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #eceae2; color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: #e1f1e4; color: #145c26; }
.badge.warn { background: #fdf0d5; color: #7a5208; }
.badge.bad { background: #f8e1e1; color: #8c1f1f; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=search], .toolbar select { width: auto; min-width: 180px; }
.thumb { width: 52px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }

/* ---------- Resumen ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; text-decoration: none; color: inherit; display: block; }
.stat:hover { border-color: var(--brand); }
.stat b { display: block; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--ink-2); }
.months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; }
.months div { text-align: center; padding: 8px 2px; border-radius: 8px; font-size: 12px; font-weight: 700; background: #f1efe8; color: var(--muted); }
.months div.ok { background: #e1f1e4; color: #145c26; }
.months div.partial { background: #fdf0d5; color: #7a5208; }

/* ---------- Mapa en panel ---------- */
.map-edit { height: 430px; border-radius: 10px; border: 1px solid var(--line); }
.map-edit.tall { height: 560px; }
.map-help { font-size: 12.5px; color: var(--ink-2); margin: 6px 0 0; }
.leaflet-draw-tooltip { font-family: inherit; }

/* ---------- Galería panel ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.photo { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.photo img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.photo .p-body { padding: 8px 10px; font-size: 12.5px; flex: 1; }
.photo .p-body strong { display: block; font-size: 13px; }
.photo .p-acts { padding: 0 10px 10px; display: flex; gap: 6px; }
.logo-prev { height: 70px; max-width: 200px; object-fit: contain; border: 1px dashed var(--line); border-radius: 10px; padding: 6px; background: #fff; display: block; margin-bottom: 6px; }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 20px; text-align: center; color: var(--ink-2); background: var(--soft); }
.dropzone.over { border-color: var(--brand); background: #eef5ec; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .cols, .cols-3-2 { grid-template-columns: minmax(0, 1fr); }
}
.cols > *, .cols-3-2 > *, .form-grid > * { min-width: 0; }
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 2000; transform: translateX(-100%); transition: transform .2s; }
  #nav-toggle:checked ~ .sidebar { transform: none; }
  #nav-toggle:checked ~ .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1999; }
  .burger { display: flex; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .tb-user { display: none; }
  .form-grid, .form-grid.g3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .months { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* ---------- Móvil: barra superior y tablas como tarjetas ---------- */
.scroll-hint { display: none; font-size: 12px; color: var(--muted); margin: 0 0 6px; }
@media (max-width: 860px) {
  .topbar { display: grid; grid-template-columns: auto minmax(0, 1fr); row-gap: 8px; }
  .topbar h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tb-right { grid-column: 1 / -1; justify-content: flex-start; }
  .mun-switch { flex: 1; min-width: 0; }
  .mun-switch select { width: 100%; }
  .panel { padding: 14px; }
  .panel-head > .actions, .panel-head > a.btn { width: 100%; }
  .toolbar input[type=search], .toolbar select, .toolbar form { width: 100%; min-width: 0; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat b { font-size: 22px; }
  .scroll-hint { display: block; }
  .actions .btn { flex: 1 1 auto; }
}
@media (max-width: 640px) {
  .table-wrap.cards-wrap { border: 0; overflow: visible; max-height: none !important; }
  table.tbl.cards, table.tbl.cards tbody { display: block; }
  table.tbl.cards thead { display: none; }
  table.tbl.cards tr { display: block; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; background: #fff; }
  table.tbl.cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: 5px 0; text-align: right; }
  table.tbl.cards td::before { content: attr(data-label); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: left; flex: none; max-width: 45%; }
  table.tbl.cards td:not([data-label])::before, table.tbl.cards td[data-label=""]::before { display: none; }
  table.tbl.cards td[data-label=""] { justify-content: flex-start; }
  table.tbl.cards td.acts { justify-content: flex-end; border-top: 1px solid #eeece5; margin-top: 4px; padding-top: 8px; }
  table.tbl.cards td input:not([type=checkbox]) { max-width: 60%; }
  table.tbl.cards tfoot { display: none; }
  .months { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .content { padding: 12px; }
}

/* ---------- Vista configurable y observaciones ---------- */
.vf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.vista-form fieldset.panel { margin: 0; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.vf-legend { font-size: 13.5px; font-weight: 800; color: var(--ink); padding: 0 6px; }
.link-mini { border: 0; background: none; color: var(--brand); font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer; margin-left: 6px; }
.obs-list { display: flex; flex-direction: column; gap: 12px; }
.obs-item { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fff; }
.obs-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.obs-text { margin: 10px 0 12px; font-size: 14px; line-height: 1.55; background: var(--soft); border-radius: 8px; padding: 10px 12px; }
.sb-link .count { margin-left: auto; }

/* Usuario de consulta: solo lectura */
.ro-banner { position: static; }
.read-only .content form[method=post] button[type=submit], .read-only .content form[method=post] .btn:not(.btn-ghost) { opacity: .85; }
@media (max-width: 860px) { .ro-banner { position: static; } }
.ro-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #18201a; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; max-width: min(520px, calc(100vw - 32px)); box-shadow: 0 10px 30px rgba(0,0,0,.25); transition: all .25s; z-index: 3000; text-align: center; }
.ro-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Créditos del autor */
.admin-autor { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); text-align: center; font-size: 12.5px; color: var(--ink-2); }
.admin-autor a, .auth-autor a { color: var(--brand); font-weight: 700; text-decoration: none; }
.auth-autor { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); text-align: center; font-size: 12px; color: var(--ink-2); }

/* Ficha del atractivo: servicios */
fieldset.checks { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 12px; }
fieldset.checks legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
fieldset.checks .span-2 { grid-column: 1 / -1; }
.badge.b-bueno, .badge.b-facil { background: #e3f1e5; color: #1f6b33; }
.badge.b-regular, .badge.b-moderada, .badge.b-por { background: #fdf1d8; color: #8a5a00; }
.badge.b-deficiente, .badge.b-critico, .badge.b-dificil, .badge.b-restringida { background: #fbe3df; color: #9b2c1f; }
