/* Emergencia360 · Diseño responsive, accesible, orientado a emergencias */
:root {
  --bg: #0f172a; --panel: #ffffff; --ink: #0f172a; --muted: #64748b;
  --line: #e2e8f0; --accent: #dc2626; --accent2: #2563eb; --ok: #059669;
  --radius: 14px; --shadow: 0 8px 30px rgba(2, 6, 23, .12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: #f1f5f9; }
a { color: var(--accent2); }

/* ── Header ── */
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--bg); color: #fff; position: sticky; top: 0; z-index: 1000; }
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: .3px; }
.brand span { color: #f87171; }
.live { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: #cbd5e1; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #475569; }
.dot.on { background: #22c55e; box-shadow: 0 0 8px #22c55e; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.spacer { flex: 1; }
.btn { border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 700; cursor: pointer; background: var(--accent); color: #fff; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: #fff; border: 1px solid #475569; }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.btn:disabled { opacity: .6; cursor: wait; }
.stat-pill { background: #1e293b; border-radius: 999px; padding: 6px 12px; font-size: .8rem; }

.banner { background: #fef2f2; border-bottom: 2px solid #fecaca; color: #7f1d1d; padding: 8px 16px; font-size: .85rem; text-align: center; }

/* ── Layout principal ── */
.layout { display: grid; grid-template-columns: 360px 1fr; gap: 12px; padding: 12px; max-width: 1400px; margin: 0 auto; min-height: calc(100vh - 120px); }
.side { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 140px); overflow: hidden; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters input, .filters select, .pane input, .pane select, .drawer input, .drawer select, .modal input, .modal select, .modal textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: .9rem; }
.filters .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 6px; font-size: .85rem; }
.list { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 2px; }
.mapbox { position: relative; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); min-height: 420px; }
#map { position: absolute; inset: 0; }
.hint { position: absolute; bottom: 10px; left: 10px; background: rgba(15,23,42,.85); color: #fff; font-size: .75rem; padding: 6px 10px; border-radius: 999px; z-index: 500; }

/* ── Tarjetas / chips ── */
.card { border: 1px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer; background: #fff; }
.card:hover, .card.sel { border-color: var(--accent2); box-shadow: 0 2px 12px rgba(37,99,235,.15); }
.card-top { display: flex; gap: 10px; align-items: flex-start; }
.emoji { font-size: 1.5rem; } .emoji.big { font-size: 2.2rem; }
.card-title { font-weight: 700; font-size: .92rem; }
.card-sub { font-size: .78rem; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: .72rem; font-weight: 700; border: 1.5px solid var(--c, #64748b); color: var(--c, #64748b); border-radius: 999px; padding: 2px 9px; background: #fff; }
.empty { color: var(--muted); text-align: center; padding: 20px; }

/* ── Marcadores ── */
.mk-wrap { background: none; border: 0; }
.mk { width: 38px; height: 38px; background: #fff; border: 3px solid #64748b; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; box-shadow: 0 2px 10px rgba(0,0,0,.35); position: relative; }
.mk-unv { position: absolute; top: -6px; right: -6px; background: #d97706; color: #fff; font-size: .65rem; font-weight: 800; width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* ── Modales / detalle ── */
.modal { border: 0; border-radius: 16px; padding: 0; max-width: 560px; width: calc(100vw - 32px); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(2,6,23,.55); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 1.05rem; }
.modal form, .modal .body { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.x { border: 0; background: #f1f5f9; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.warn { background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 10px; font-size: .82rem; }
.muted { color: var(--muted); font-size: .82rem; }
.error { color: #b91c1c; }
#pick-map { height: 220px; border-radius: 10px; border: 1px solid var(--line); }
.d-photo { width: 100%; border-radius: 10px; margin-top: 8px; }
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } .d-grid dt { font-size: .72rem; color: var(--muted); } .d-grid dd { margin: 0; font-size: .88rem; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 3px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.timeline time { font-size: .75rem; color: var(--muted); }

/* ── Toasts ── */
#toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 3000; }
.toast { background: var(--bg); color: #fff; padding: 12px 16px; border-radius: 10px; opacity: 0; transform: translateY(8px); transition: .3s; max-width: 340px; font-size: .88rem; }
.toast.show { opacity: 1; transform: none; }
.toast-ok { border-left: 4px solid #22c55e; } .toast-error { border-left: 4px solid #ef4444; }

footer { text-align: center; color: var(--muted); font-size: .78rem; padding: 14px; }

/* ── Panel privado ── */
.wrap { max-width: 1200px; margin: 0 auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; }
.stat-v { font-size: 1.6rem; font-weight: 800; } .stat-l { font-size: .78rem; color: var(--muted); }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: #f8fafc; border-radius: 999px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.tab.on { background: var(--bg); color: #fff; }
.pane { display: none; } .pane.on { display: block; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
tr[data-id] { cursor: pointer; } tr[data-id]:hover { background: #f8fafc; }
.row-btns button, .pane button { border: 1px solid var(--line); background: #f8fafc; border-radius: 8px; padding: 6px 10px; cursor: pointer; margin: 2px; }
.row-btns button:hover { background: #e2e8f0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.drawer { position: fixed; top: 0; right: -420px; width: min(400px, 100vw); height: 100vh; background: #fff; box-shadow: -8px 0 30px rgba(0,0,0,.2); transition: right .25s; z-index: 2000; padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.drawer.open { right: 0; }
.devbox { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: #fffbeb; border: 1px dashed #d97706; border-radius: 10px; padding: 8px 12px; font-size: .8rem; }
.locked { padding: 30px; text-align: center; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { max-height: none; order: 2; }
  .mapbox { min-height: 55vh; order: 1; }
  .topbar { flex-wrap: wrap; }
}
