:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #15202b;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0a7cff;
  --brand-dark: #0759b8;
  --ok: #12a150;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1em; }
h2 { font-size: 16px; margin: 0 0 12px; }
a { color: var(--brand); cursor: pointer; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; }

#app { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: #0f172a; color: #e2e8f0; padding: 20px 14px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a { color: #cbd5e1; padding: 9px 12px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; text-decoration: none; }
.sidebar nav a:hover { background: #1e293b; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.badge { background: var(--bad); color: #fff; border-radius: 99px; padding: 1px 7px; font-size: 11px; }
.badge:empty { display: none; }
main { flex: 1; padding: 20px 28px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; }
.topbar h1 { font-size: 22px; margin: 0; }
.pill { background: #e0edff; color: var(--brand-dark); padding: 6px 12px; border-radius: 99px; font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; }
input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--brand); }

.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 8px; cursor: pointer; color: var(--text); }
.btn:hover { filter: brightness(0.97); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: #fff; border-color: #fecaca; color: var(--bad); }
.btn.ghost { background: transparent; color: #cbd5e1; border-color: #334155; }
.btn:disabled { opacity: 0.5; cursor: default; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.table-wrap { overflow-x: auto; }

.status { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #f1f5f9; }
.status.pending, .status.payment_review, .status.awaiting_payment { background: #fef3c7; color: #92400e; }
.status.approved, .status.confirmed, .status.paid, .status.completed, .status.published { background: #dcfce7; color: #166534; }
.status.rejected, .status.cancelled, .status.expired { background: #fee2e2; color: #991b1b; }

/* Etapas del dinero de una reserva pagada */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.steps li { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #f1f5f9; color: var(--muted); }
.steps li.done { background: #dcfce7; color: #166534; }
.steps li.current { background: var(--brand); color: #fff; font-weight: 600; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.pager { justify-content: center; margin-top: 12px; }

.payment { display: grid; grid-template-columns: 220px 1fr; gap: 18px; }
.payment img.receipt { width: 100%; max-height: 340px; object-fit: contain; border-radius: 8px; border: 1px solid var(--line); background: #f8fafc; cursor: zoom-in; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 4px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.amount { font-size: 22px; font-weight: 800; }
.docs { display: flex; gap: 10px; flex-wrap: wrap; }
.docs figure { margin: 0; width: 170px; }
.docs img { width: 170px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.docs figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); display: grid; place-items: center; padding: 20px; z-index: 10; }
.modal-body { background: #fff; border-radius: var(--radius); padding: 20px; max-width: min(900px, 100%); max-height: 90vh; overflow: auto; }
.modal-body img { max-width: 100%; max-height: 80vh; display: block; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 20; }

@media (max-width: 800px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  main { padding: 16px; }
  .payment { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
}

/* Alerta de SOS: visible en todas las secciones hasta que alguien la atienda */
.sos-banner { position: sticky; top: 0; z-index: 20; display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; margin-bottom: 12px; border-radius: 10px; background: #b91c1c; color: #fff; font-weight: 600; animation: sos-pulse 1.2s ease-in-out infinite; }
.sos-banner .sos-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.sos-banner button { background: #fff; color: #b91c1c; border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 700; cursor: pointer; }
.sos-banner small { font-weight: 500; opacity: .9; }
@keyframes sos-pulse { 50% { background: #ef4444; } }
@media (prefers-reduced-motion: reduce) { .sos-banner { animation: none; } }
.sos-map { width: 100%; height: 320px; border: 0; border-radius: 10px; }
