:root {
  --accent: #b11116;
  --accent-d: #8a0d11;
  --accent-soft: #fdecec;
  --bg: #f7f7f8;
  --card: #ffffff;
  --line: #ececef;
  --txt: #18181b;
  --muted: #71717a;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--txt); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--accent); min-height: 1em; }
button { font: inherit; cursor: pointer; }

/* ---- Login ---- */
.login { display: flex; align-items: center; justify-content: center; height: 100%; padding: 20px; }
.login-card {
  background: var(--card); padding: 36px 32px; border-radius: 22px; width: 100%; max-width: 360px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px;
}
.brand { color: var(--accent); margin: 0 0 8px; font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.brand span { color: var(--txt); font-weight: 400; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input { padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); font-size: 16px; background: #fafafa; }
.login-card input:focus { outline: none; border-color: var(--accent); background: #fff; }
.login-card button { padding: 13px; border-radius: 12px; border: none; font-size: 16px; font-weight: 600; background: var(--accent); color: #fff; }

/* ---- Topbar ---- */
.topbar {
  display: flex; align-items: center; gap: 16px; background: var(--card);
  padding: 12px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand-sm { color: var(--accent); font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.brand-sm span { color: var(--txt); font-weight: 400; }
.topbar-tabs { flex: 1; }
.topbar .tab { background: transparent; color: var(--muted); border: none; padding: 8px 14px; border-radius: 10px; font-weight: 600; }
.topbar .tab.active { background: var(--accent-soft); color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.usuario { font-size: 13px; color: var(--muted); }
.link { background: none; border: none; color: var(--accent); text-decoration: none; font-weight: 600; }

main { padding: 24px; max-width: 1180px; margin: 0 auto; }

/* ---- Botones ---- */
.prim { background: var(--accent); color: #fff; border: none; padding: 11px 18px; border-radius: 12px; font-weight: 600; }
.sec { background: var(--card); border: 1px solid var(--line); padding: 11px 16px; border-radius: 12px; font-weight: 500; }
.danger { background: #fff; color: var(--accent); border: 1px solid var(--accent); padding: 11px 16px; border-radius: 12px; font-weight: 600; }
.chip { background: var(--card); border: 1px solid var(--line); padding: 8px 14px; border-radius: 999px; font-size: 13px; color: var(--muted); }
.chip:hover { border-color: #d4d4d8; }

/* ---- Listado ---- */
.list-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.searchbar { flex: 1; display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0 16px; box-shadow: var(--shadow); }
.searchbar .ic { color: var(--muted); }
.searchbar input { flex: 1; border: none; background: none; padding: 15px 0; font-size: 16px; outline: none; color: var(--txt); }
.list-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.list-tools #selBusq { margin-left: auto; }
#contador { font-size: 13px; }

.filtros { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.filtros-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.filtros label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
.filtros input, .filtros select { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; background: #fafafa; }
.filtros input:focus, .filtros select:focus { outline: none; border-color: var(--accent); background: #fff; }
.filtros-acc { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

select.chip, #selBusq { appearance: none; -webkit-appearance: none; }

/* ---- Listado en tabla (compacto, escala a miles) ---- */
.tabla-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 230px); }
.listado-tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.listado-tabla thead th { position: sticky; top: 0; background: #fafafa; text-align: left; padding: 8px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 1; }
.listado-tabla tbody td { padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.listado-tabla .nom { white-space: normal; }
.listado-tabla tbody tr { cursor: pointer; }
.listado-tabla tbody tr:hover { background: var(--accent-soft); }
.listado-tabla .nom { font-weight: 600; }
.listado-tabla .id { color: #a1a1aa; }
.listado-tabla .chk { width: 40px; text-align: center; }
.listado-tabla .chk input { width: 18px; height: 18px; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; letter-spacing: .02em; }
.b-tienda { background: #e8f0fe; color: #1a56c4; }
.b-part { background: #eaf6e6; color: #2f7a1d; }
.vacio { text-align: center; color: var(--muted); padding: 40px; }

/* ---- Ficha (compacta: que entre todo de una) ---- */
.ficha-acc { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.ficha-acc h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.ficha-acc h2 small { color: var(--muted); font-weight: 400; font-size: 14px; }
.spacer { flex: 1; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; align-items: start; }

/* ---- Baraja de tarjetas solapadas (cascada) ---- */
.deck { position: relative; margin-bottom: 4px; }
.deck .deck-card {
  position: absolute; top: 0; left: 0; width: 280px; height: 172px; overflow: hidden;
  border-radius: 14px; transition: transform .18s ease, box-shadow .18s ease;
  cursor: pointer; box-shadow: 0 3px 12px rgba(0,0,0,.10);
}
.deck .deck-card.front { height: auto; overflow: visible; box-shadow: 0 18px 40px rgba(0,0,0,.22); border-color: var(--accent); }
.deck .deck-card.front legend { cursor: pointer; }
.deck .deck-card.front legend { color: var(--accent); }
.deck .deck-card:not(.front) { opacity: .97; }
/* Móvil: se apilan en vertical y ocupan el ancho */
.deck.stacked { display: flex; flex-direction: column; gap: 10px; height: auto !important; }
.deck.stacked .deck-card { position: static; width: auto; height: auto; overflow: visible; box-shadow: var(--shadow); }
fieldset { border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 11px 13px; box-shadow: var(--shadow); }
legend { font-size: 11px; color: var(--accent); font-weight: 700; padding: 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.f { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 7px; }
.f input, .f select, .f textarea { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; color: var(--txt); background: #fafafa; font-weight: 400; }
.f input:focus, .f select:focus, .f textarea:focus { outline: none; border-color: var(--accent); background: #fff; }
.f textarea { min-height: 44px; }
.row { display: flex; gap: 8px; }
.row .f { flex: 1; }

/* ---- Campo con icono (teléfono / Maps) ---- */
.con-ico { display: flex; gap: 6px; align-items: stretch; }
.con-ico input { flex: 1; min-width: 0; }
.ico-btn { border: 1px solid var(--line); background: #fafafa; border-radius: 8px; padding: 0 11px; cursor: pointer; font-size: 15px; line-height: 1; }
.ico-btn:hover { background: var(--accent-soft); border-color: var(--accent); }

/* ---- Pestañas ficha ---- */
.pestanas { margin-top: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.pest-nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); background: #fafafa; }
.pest { background: transparent; border: none; padding: 7px 13px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 13px; }
.pest.active { background: var(--accent-soft); color: var(--accent); }
.pest-cuerpo { padding: 14px; }

/* ---- Tabla mini (contactos / datos bancarios) ---- */
.tabla { width: 100%; border-collapse: collapse; }
.tabla th, .tabla td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.tabla thead th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tabla.mini input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 7px; background: #fafafa; }
.del-ct { background: none; border: none; color: var(--accent); font-size: 16px; }

@media (max-width: 600px) {
  main { padding: 16px; }
  .list-head { flex-wrap: wrap; }
}
