*{box-sizing:border-box}
body{
  margin:0;
  background:#f5f0e8;
  color:#2A2A1C;
  font-family:'DM Sans',sans-serif;
}
.topbar{
  height:60px;
  background:linear-gradient(90deg,#8B1A1A 0%,#B83D26 100%);
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 16px;
}
.brand{display:flex;align-items:center;gap:12px}
.brand img{height:36px}
.brand small{display:block;font-size:10px;opacity:.8}
.brand strong{font-size:15px}
.top-link{
  color:#fff;
  text-decoration:none;
  font-size:12px;
  border:1px solid rgba(255,255,255,.3);
  border-radius:999px;
  padding:7px 12px;
}
.layout{min-height:calc(100vh - 60px);padding:10px 14px;max-width:1200px;margin:0 auto}
.muted{color:#746b5f;font-size:12px}

/* ── LAYOUT ─────────────────────────────────── */
.ficha-body{display:flex;gap:12px}
.ficha-form-col{flex:1;min-width:0}
.ficha-map-col{flex:0 0 360px;display:none;position:sticky;top:76px;align-self:flex-start}
.ficha-map-col.active{display:block}
#editor-map,#editor-map-col{min-height:350px;border-radius:10px;border:1px solid #e5ddd0;overflow:hidden;background:#f0ece6}
.geo-results{max-height:140px;overflow:auto;margin-top:6px;border:1px solid #efe8db;border-radius:8px}
.map-search-row{display:flex;gap:6px;margin-top:8px}
.map-search-row input{flex:1}

/* ── FORMULARIO COMPACTO ────────────────────── */
.form-row-2col{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:8px}
.form-field{margin-bottom:8px;display:flex;flex-direction:column}
.form-field label{font-size:11px;font-weight:600;color:#3b342c;margin-bottom:3px}
.form-field input,.form-field select,.form-field textarea{font-size:13px;padding:7px 9px;border:1px solid #d8cfbf;border-radius:6px;font-family:inherit;background:#fff}
.form-field textarea{min-height:70px;resize:vertical}

@media(max-width:800px){
  .form-row-2col{grid-template-columns:1fr}
  .ficha-body{flex-direction:column}
  .ficha-map-col{flex:1;min-height:300px}
}
.card{
  background:#fff;
  border:1px solid #e5ddd0;
  border-radius:12px;
  padding:12px;
  margin-top:10px;
}
label{
  display:block;
  margin:8px 0 4px;
  font-size:12px;
  font-weight:600;
  color:#3b342c;
}
input,select,textarea,button{
  font-family:inherit;
  font-size:13px;
}
input,select,textarea{
  width:100%;
  border:1px solid #d8cfbf;
  border-radius:8px;
  padding:9px 10px;
  background:#fff;
}
#ficha_consecutivo{max-width:160px}
input[readonly]{background:#f3efe7;color:#4b4134}
textarea{min-height:74px;resize:vertical}
.form-section{border:1px solid #eee4d7;border-radius:10px;padding:10px 10px 12px;margin-bottom:10px;background:#fffdf9}
.form-section h3{margin:0 0 6px;font-size:13px;text-transform:uppercase;letter-spacing:.5px;color:#5b4e3f}
#descripcion_fisica,#relato_historico{min-height:120px;resize:both}
.row{
  display:grid;
  grid-template-columns:1fr auto;
  gap:8px;
}
.row > div{min-width:0}
#ficha-form .row{
  grid-template-columns:1fr 1fr;
}
button{
  border:none;
  background:#2A2A1C;
  color:#F3D2A1;
  border-radius:8px;
  padding:10px 12px;
  cursor:pointer;
}
.btn-light{
  background:#ece7dc;
  color:#2A2A1C;
}
.actions{
  display:flex;
  gap:8px;
  margin-top:12px;
}
.actions button{flex:1}
.result-list,.geo-results{
  max-height:180px;
  overflow:auto;
  margin-top:8px;
  border:1px solid #efe8db;
  border-radius:8px;
}
.result-item{
  padding:8px 10px;
  border-bottom:1px solid #f4eee3;
  cursor:pointer;
  font-size:12px;
}
.result-item:last-child{border-bottom:none}
.result-item:hover{background:#faf7f1}
#status-box{
  margin-top:8px;
  padding:8px 12px;
  border-radius:8px;
  background:#eee5d7;
  font-size:12px;
  font-weight:500;
  text-align:center;
  transition:all .3s;
}
#status-box.ok{background:#e8f5e9;color:#1b5e20;border:1px solid #a5d6a7}
#status-box.err{background:#ffebee;color:#b71c1c;border:1px solid #ef9a9a}
.map-tools .row{grid-template-columns:1fr auto}
#editor-map{
  flex:1;
  min-height:520px;
  border:1px solid #e5ddd0;
  border-radius:12px;
  overflow:hidden;
}
@media (max-width: 900px){
  .ficha-body{flex-direction:column}
  .ficha-map-col{position:static;min-height:350px}
  .ficha-map-col.active{min-height:350px}
  #editor-map{min-height:350px}
  .ficha-header{flex-direction:column;align-items:flex-start}
  .ficha-header-actions{width:100%}
  .ficha-header-actions button{flex:1}
  .subtab-btn{font-size:11px;padding:8px 6px}
  .subtab-btn i{margin-right:3px}
}

/* ── TABS ─────────────────────────────────────────── */
.tab-bar{display:flex;gap:0;margin-top:12px;border-bottom:2px solid #e5ddd0}
.tab-btn{
  background:none;border:none;border-bottom:2px solid transparent;
  margin-bottom:-2px;padding:10px 16px;font-size:13px;font-weight:600;
  color:#746b5f;cursor:pointer;font-family:inherit;transition:all .2s;
}
.tab-btn i{margin-right:6px}
.tab-btn.active{color:#B83D26;border-bottom-color:#B83D26}
.tab-btn:hover:not(.active){color:#2A2A1C;background:#faf7f1}
.tab-content{display:none}
.tab-content.active{display:block}

/* ── FICHA HEADER ─────────────────────────────── */
.ficha-header{
  background:#fff;border:1px solid #e5ddd0;border-radius:12px;
  padding:14px 18px;margin-bottom:10px;display:flex;
  align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px;
}
.ficha-header-id{display:flex;align-items:center;gap:8px}
.ficha-badge{
  font-size:11px;font-weight:700;padding:4px 10px;border-radius:6px;
  text-transform:uppercase;letter-spacing:.5px;
}
.ficha-badge:first-child{background:#2A2A1C;color:#F3D2A1}
.ficha-badge-status{background:#f5f0e8;color:#746b5f}
.ficha-badge-status.pub{background:#e8f5e9;color:#2e7d32}
.ficha-badge-status.unpub{background:#fff3e0;color:#e65100}
 .ficha-header-main{
   flex:1;min-width:200px;
 }
 .ficha-header-title{
   margin:0;font-size:24px;font-weight:700;color:#2A2A1C;line-height:1.3;word-break:break-word;
 }
 .ficha-header-sub{
   font-size:14px;color:#746b5f;margin-top:2px;font-weight:400;
 }
 .ficha-header-actions{display:flex;gap:6px;align-items:center}

/* ── SUBTABS (bloques internos del formulario) ──── */
.subtab-bar{display:flex;gap:0;flex-wrap:wrap;margin:0 0 12px;border-bottom:1px solid #e5ddd0;background:#fdfcfa;border-radius:10px 10px 0 0;overflow:hidden}
.subtab-btn{
  background:none;border:none;padding:10px 12px;font-size:12px;font-weight:500;
  color:#746b5f;cursor:pointer;font-family:inherit;transition:all .2s;
  flex:1;text-align:center;border-bottom:2px solid transparent;
  white-space:nowrap;min-width:0;
}
.subtab-btn i{margin-right:5px;font-size:11px}
.subtab-btn.active{color:#B83D26;border-bottom-color:#B83D26;background:#fff;font-weight:600}
.subtab-btn:hover:not(.active){color:#2A2A1C;background:#faf7f1}
.subtab-content{display:none}
.subtab-content.active{display:block}
.subtab-content .form-section{margin-bottom:8px}
.subtab-content .geo-section{margin-top:12px}

/* ── GALLERY ──────────────────────────────────────── */
.gallery-card{padding:0;overflow:hidden;border-radius:12px}
.gallery-header{padding:14px 16px 10px;border-bottom:1px solid #efe8db;display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:6px}
.gallery-header h3{margin:0;font-size:14px;color:#2A2A1C}
.gallery-header small{color:#746b5f;font-size:11px}
.gallery-upload-bar{padding:10px 16px;border-bottom:1px solid #efe8db;display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.btn-upload{
  background:#B83D26;color:#fff;border:none;border-radius:8px;
  padding:9px 16px;font-size:13px;cursor:pointer;font-family:inherit;
  display:flex;align-items:center;gap:6px;transition:background .2s;
}
.btn-upload:hover{background:#8B1A1A}
.btn-upload:disabled{opacity:.5;cursor:not-allowed}
.upload-progress{display:none;align-items:center;gap:10px;flex:1;min-width:200px}
.upload-bar-bg{flex:1;height:8px;background:#eee;border-radius:4px;overflow:hidden}
.upload-bar-fill{height:100%;background:linear-gradient(90deg,#B83D26,#e85d3a);border-radius:4px;transition:width .3s ease;width:0}
#upload-status-text{font-size:12px;color:#746b5f;white-space:nowrap;min-width:120px}
.gallery-grid{
  padding:14px 16px;
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(180px, 1fr));
  gap:14px;
  min-height:200px;
}
.gallery-empty{
  grid-column:1/-1;text-align:center;padding:56px 16px;color:#a09688;
}
.gallery-empty i{font-size:40px;display:block;margin-bottom:12px;opacity:.4;color:#c9bfaf}
.gallery-empty p{margin:0;font-size:14px;font-weight:500}
.gallery-empty small{font-size:12px;color:#b6aa98;margin-top:4px;display:block}
.gallery-grid.drag-over{outline:2px dashed #B83D26;background:#fdf6f0;border-radius:8px}

/* Photo card — diseño tipo Instagram */
.photo-card{
  background:#fff;border:1px solid #e8dfd0;border-radius:12px;
  overflow:hidden;position:relative;cursor:default;transition:all .25s ease;display:flex;flex-direction:column;
}
.photo-card:hover{box-shadow:0 4px 20px rgba(0,0,0,.12);border-color:#d5caba;transform:translateY(-2px)}
.photo-card.is-portada{border-color:#B83D26;box-shadow:0 0 0 2px rgba(184,61,38,.3)}
.photo-thumb-wrap{position:relative;overflow:hidden;background:#f3efe7;flex-shrink:0}
.photo-thumb{
  width:100%;aspect-ratio:16/10;object-fit:cover;display:block;cursor:pointer;
  transition:transform .4s ease;
}
.photo-card:hover .photo-thumb{transform:scale(1.05)}
.photo-thumb-badges{position:absolute;top:8px;left:8px;right:8px;display:flex;gap:4px;justify-content:space-between;pointer-events:none;z-index:2}
.badge-portada{background:#B83D26;color:#fff;font-size:9px;font-weight:700;padding:3px 8px;border-radius:5px;text-transform:uppercase;letter-spacing:.5px;box-shadow:0 1px 4px rgba(0,0,0,.2)}
.badge-unpub{background:#d97706;color:#fff;font-size:9px;font-weight:700;padding:3px 8px;border-radius:5px;text-transform:uppercase;letter-spacing:.5px;box-shadow:0 1px 4px rgba(0,0,0,.2)}
.badge-count{background:rgba(0,0,0,.5);color:#fff;font-size:10px;padding:2px 8px;border-radius:5px}
.photo-info{padding:10px 10px 4px;flex:1}
.photo-tipo{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.6px;color:#B83D26}
.photo-meta{font-size:11px;color:#746b5f;margin-top:3px;line-height:1.4}
.photo-actions{
  display:flex;gap:0;border-top:1px solid #f0e8dc;margin-top:6px;padding:0;
}
.photo-actions button{
  background:none;border:none;padding:8px 4px;font-size:11px;cursor:pointer;color:#746b5f;
  font-family:inherit;transition:all .15s;flex:1;display:flex;align-items:center;justify-content:center;gap:4px;border-right:1px solid #f0e8dc;
}
.photo-actions button:last-child{border-right:none}
.photo-actions button:hover{background:#f5f0e8;color:#2A2A1C}
.photo-actions .btn-star:hover{color:#f59e0b}
.photo-actions .btn-eye:hover{color:#2563eb}
.photo-actions .btn-edit:hover{color:#B83D26}

/* ── FOTO EDIT MODAL ──────────────────────────────── */
.foto-modal{position:fixed;inset:0;z-index:9000}
.foto-modal-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.5)}
.foto-modal-box{
  position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);
  background:#fff;border-radius:14px;width:420px;max-width:95vw;
  box-shadow:0 12px 40px rgba(0,0,0,.25);overflow:hidden;
}
.foto-modal-header{
  display:flex;justify-content:space-between;align-items:center;
  padding:14px 16px;border-bottom:1px solid #efe8db;
}
.foto-modal-header h4{margin:0;font-size:15px}
.foto-modal-close{background:none;border:none;font-size:18px;cursor:pointer;color:#746b5f;padding:4px 8px}
.foto-modal-body{padding:14px 16px;max-height:60vh;overflow-y:auto}
.foto-modal-body label{display:block;margin:10px 0 4px;font-size:12px;font-weight:600;color:#3b342c}
.foto-modal-body input[type="date"],
.foto-modal-body input[type="text"],
.foto-modal-body textarea{width:100%;border:1px solid #d8cfbf;border-radius:8px;padding:9px 10px;font-size:13px;font-family:inherit}
.foto-modal-body textarea{min-height:60px;resize:vertical}
.checkbox-label{display:flex!important;align-items:center;gap:8px;cursor:pointer}
.checkbox-label input[type="checkbox"]{width:auto}
.foto-modal-footer{display:flex;justify-content:space-between;align-items:center;padding:10px 16px;border-top:1px solid #efe8db;gap:8px}
.btn-danger{background:#dc2626;color:#fff;border:none;border-radius:8px;padding:9px 14px;cursor:pointer;font-family:inherit;font-size:13px}
.btn-danger:hover{background:#b91c1c}
.btn-primary{background:#2A2A1C;color:#F3D2A1;border:none;border-radius:8px;padding:9px 14px;cursor:pointer;font-family:inherit;font-size:13px}
.btn-primary:hover{background:#1e1e14}

/* ── LIGHTBOX ─────────────────────────────────────── */
.lightbox{position:fixed;inset:0;z-index:9500}
.lightbox-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.9)}
.lightbox-content{
  position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);
  max-width:90vw;max-height:90vh;display:flex;flex-direction:column;align-items:center;
}
.lightbox-content img{max-width:90vw;max-height:75vh;border-radius:8px;box-shadow:0 4px 24px rgba(0,0,0,.4)}
.lightbox-close{
  position:fixed;top:16px;right:16px;background:rgba(255,255,255,.15);
  border:none;color:#fff;font-size:24px;cursor:pointer;border-radius:50%;
  width:40px;height:40px;z-index:9501;
}
.lightbox-close:hover{background:rgba(255,255,255,.3)}
.lightbox-nav{
  position:fixed;top:50%;transform:translateY(-50%);
  background:rgba(255,255,255,.15);border:none;color:#fff;font-size:28px;
  cursor:pointer;border-radius:50%;width:48px;height:48px;z-index:9501;
}
.lightbox-nav:hover{background:rgba(255,255,255,.3)}
.lightbox-prev{left:16px}
.lightbox-next{right:16px}
.lightbox-caption{
  color:#fff;text-align:center;margin-top:14px;font-size:13px;
  max-width:600px;line-height:1.6;padding:0 16px;
}
.lightbox-caption strong{display:block;font-size:16px;margin-bottom:4px}
.lightbox-caption .tipo-badge{
  display:inline-block;background:#B83D26;color:#fff;padding:2px 10px;
  border-radius:999px;font-size:10px;font-weight:700;text-transform:uppercase;
  letter-spacing:.5px;margin-bottom:6px;
}
.lightbox-caption small{color:rgba(255,255,255,.7)}
.lightbox-caption small i{margin-right:4px}

/* ── TOAST NOTIFICATIONS ──────────────────────────── */
.toast-container{
  position:fixed;top:72px;right:16px;z-index:9999;
  display:flex;flex-direction:column;gap:8px;
  pointer-events:none;max-width:420px;width:100%;
}
.toast{
  pointer-events:auto;
  background:#fff;border-radius:10px;padding:14px 16px;
  box-shadow:0 6px 24px rgba(0,0,0,.14);
  border-left:4px solid #746b5f;
  display:flex;align-items:flex-start;gap:10px;
  font-size:13px;line-height:1.5;
  transform:translateX(120%);opacity:0;
  transition:transform .35s cubic-bezier(.22,.68,0,1), opacity .3s ease;
  animation: toastIn .35s cubic-bezier(.22,.68,0,1) forwards;
}
.toast.toast-out{
  animation: toastOut .3s ease forwards;
}
@keyframes toastIn{
  0%{transform:translateX(120%);opacity:0}
  100%{transform:translateX(0);opacity:1}
}
@keyframes toastOut{
  0%{transform:translateX(0);opacity:1}
  100%{transform:translateX(120%);opacity:0}
}
.toast-icon{flex-shrink:0;font-size:16px;margin-top:1px}
.toast-body{flex:1;min-width:0}
.toast-title{font-weight:600;font-size:13px;color:#2A2A1C}
.toast-desc{font-size:12px;color:#746b5f;margin-top:2px;word-break:break-word}
.toast-close{
  flex-shrink:0;background:none;border:none;cursor:pointer;
  font-size:14px;color:#a09688;padding:2px 4px;margin:-2px;
}
.toast-close:hover{color:#2A2A1C}
.toast.success{border-left-color:#2e7d32}
.toast.success .toast-icon{color:#2e7d32}
.toast.error{border-left-color:#c62828}
.toast.error .toast-icon{color:#c62828}
.toast.info{border-left-color:#1565c0}
.toast.info .toast-icon{color:#1565c0}
.toast.warning{border-left-color:#e65100}
.toast.warning .toast-icon{color:#e65100}
.toast.loading{border-left-color:#746b5f}
.toast.loading .toast-icon{color:#746b5f}

/* ── DOCUMENTOS ─────────────────────────────────── */
.docs-grid{
  padding:14px 16px;
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(280px, 1fr));
  gap:12px;
  min-height:150px;
}
.doc-card{
  background:#fff;border:1px solid #e8dfd0;border-radius:12px;
  overflow:hidden;transition:all .25s ease;display:flex;flex-direction:column;
}
.doc-card:hover{box-shadow:0 4px 20px rgba(0,0,0,.12);border-color:#d5caba;transform:translateY(-2px)}
.doc-card-body{padding:14px;flex:1;display:flex;gap:12px;align-items:flex-start}
.doc-icon{font-size:32px;color:#B83D26;flex-shrink:0;margin-top:2px}
.doc-info{flex:1;min-width:0}
.doc-name{font-weight:600;font-size:13px;color:#2A2A1C;word-break:break-word;line-height:1.3}
.doc-meta{font-size:11px;color:#746b5f;margin-top:4px;display:flex;flex-wrap:wrap;gap:4px 10px}
.doc-meta span{white-space:nowrap}
.doc-desc{font-size:12px;color:#746b5f;margin-top:4px;line-height:1.4}
.doc-card-actions{
  display:flex;gap:0;border-top:1px solid #f0e8dc;
}
.doc-card-actions button{
  background:none;border:none;padding:8px 4px;font-size:11px;cursor:pointer;color:#746b5f;
  font-family:inherit;transition:all .15s;flex:1;display:flex;align-items:center;justify-content:center;gap:4px;border-right:1px solid #f0e8dc;
}
.doc-card-actions button:last-child{border-right:none}
.doc-card-actions button:hover{background:#f5f0e8;color:#2A2A1C}
.doc-card-actions .btn-download:hover{color:#1565c0}
.doc-card-actions .btn-edit:hover{color:#B83D26}
.doc-card-actions .btn-delete:hover{color:#c62828}
#doc-drop-zone.drag-over{border-color:#B83D26;background:#fdf6f0}
@media (max-width: 600px){
  .toast-container{right:8px;left:8px;max-width:none;top:64px}
}

@media (max-width: 600px){
  .lightbox-nav{width:36px;height:36px;font-size:18px}
  .lightbox-prev{left:4px}
  .lightbox-next{right:4px}
  .lightbox-close{top:8px;right:8px;width:36px;height:36px;font-size:20px}
}
.form-row-3{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}@media(max-width:768px){.form-row-3{grid-template-columns:1fr}}
