/* ═══════════════════════════════════════════════════════════
   MapStock — sistema de diseño
   Plataforma web responsiva. Sin frameworks CSS, sin build step.
   ═══════════════════════════════════════════════════════════ */

:root {
  --blue: #1A73E8;
  --blue-d: #0D5DBF;
  --blue-l: #5B9BF0;
  --green: #00C896;
  --green-d: #009E78;
  --green-ink: #00795C;
  --red: #E53935;
  --red-ink: #C62828;
  --amber: #F59E0B;
  --amber-ink: #B45309;
  --purple: #8B5CF6;
  --dark: #0A0F1E;
  --dark-2: #111827;
  --dark-3: #12233F;
  --ink: #1B2130;
  --muted: #6B7894;
  --muted-2: #9AA3B8;
  --cream: #F4F6FA;
  --line: #E4E8EF;
  --line-2: #F0F3F8;
  --white: #fff;

  --r-sm: 9px;
  --r: 12px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 6px 20px rgba(16, 24, 40, .10);
  --shadow-lg: 0 18px 44px rgba(10, 15, 30, .18);

  --nav-h: 60px;
  --header-h: 60px;
  --maxw: 1180px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'DM Sans', system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--cream);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: 'Syne', 'DM Sans', sans-serif; font-weight: 800; margin: 0; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; }
p { margin: 0; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: #C9D0DC; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

.material-symbols-outlined { font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; vertical-align: middle; }
.fill-1 { font-variation-settings: 'FILL' 1, 'wght' 500; }

/* ── tipografía utilitaria (set mínimo, no un clon de Tailwind) ── */
.display { font-family: 'Syne', sans-serif; font-weight: 800; }
.t-xs { font-size: 10px; }
.t-sm { font-size: 11.5px; }
.t-md { font-size: 13px; }
.t-lg { font-size: 16px; }
.b6 { font-weight: 600; }
.b7 { font-weight: 700; }
.b8 { font-weight: 800; }
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.c-blue { color: var(--blue); }
.c-green { color: var(--green-ink); }
.c-red { color: var(--red-ink); }
.c-amber { color: var(--amber-ink); }
.center { text-align: center; }
.right { text-align: right; }
.strike { text-decoration: line-through; }
.upper { text-transform: uppercase; letter-spacing: .05em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── layout ── */
.row { display: flex; align-items: center; gap: 10px; }
.row-top { display: flex; align-items: flex-start; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.gap-sm { gap: 6px; }
.gap-lg { gap: 16px; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.hidden { display: none !important; }

.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; width: 100%; }
.container-sm { max-width: 560px; margin: 0 auto; padding: 0 16px; width: 100%; }

/* ═══════════ shell de la app (comprador) ═══════════ */
.app { display: flex; flex-direction: column; min-height: 100dvh; }
.app-main { flex: 1; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }

.topbar {
  background: linear-gradient(135deg, var(--dark), var(--dark-3));
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar .container { display: flex; align-items: center; gap: 12px; min-height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-name { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 16px; line-height: 1; }
.brand-name .a { color: var(--blue-l); }
.brand-name .b { color: var(--green); }

.loc-btn {
  background: none; border: none; padding: 0; cursor: pointer; font: inherit;
  display: flex; align-items: center; gap: 3px; color: var(--muted-2); font-size: 11px; margin-top: 2px;
}
.loc-btn:hover { color: #fff; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2);
  color: #fff; font-weight: 700; font-size: 11.5px; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center; text-decoration: none;
}
.avatar:hover { background: rgba(255, 255, 255, .2); text-decoration: none; }
.avatar-lg {
  width: 66px; height: 66px; font-size: 23px; font-family: 'Syne', sans-serif; font-weight: 800;
  background: linear-gradient(135deg, var(--blue), var(--green)); border: 2px solid rgba(255, 255, 255, .35);
}

/* nav inferior en mobile, superior en desktop */
.bnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding: 6px 4px calc(9px + env(safe-area-inset-bottom));
}
.btab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  color: var(--muted-2); font-size: 9.5px; font-weight: 600; padding: 4px; border-radius: var(--r-sm);
  background: none; border: none; font-family: inherit; cursor: pointer; text-decoration: none;
}
.btab:hover { text-decoration: none; }
.btab .material-symbols-outlined { font-size: 22px; }
.btab.on { color: var(--blue); }
.btab.on .material-symbols-outlined { font-variation-settings: 'FILL' 1, 'wght' 600; }

/* ── buscador ── */
.searchbox {
  display: flex; align-items: center; background: #fff; border-radius: var(--r);
  padding: 0 4px 0 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
}
.searchbox input {
  border: none; box-shadow: none !important; flex: 1; font-size: 14px; padding: 12px 8px; background: none;
}
.searchbox input:focus { border: none; }
.btn-ai {
  background: linear-gradient(135deg, var(--purple), var(--blue)); border: none; border-radius: var(--r-sm);
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  color: #fff; cursor: pointer; flex-shrink: 0; text-decoration: none;
}
.btn-ai:hover { text-decoration: none; filter: brightness(1.08); }

/* ── componentes ── */
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.card-p { padding: 14px; }
.card-link { width: 100%; text-align: left; font-family: inherit; color: inherit; cursor: pointer; }
.card-link:hover { text-decoration: none; border-color: #C7D6EE; box-shadow: var(--shadow-md); }

.btn {
  border: none; cursor: pointer; font-family: inherit; font-weight: 700; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: .16s; font-size: 13px; padding: 10px 16px; text-decoration: none; line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .material-symbols-outlined { font-size: 17px; }
.btn-p { background: linear-gradient(135deg, var(--blue), var(--blue-d)); color: #fff; box-shadow: 0 3px 12px rgba(26, 115, 232, .32); }
.btn-p:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(26, 115, 232, .42); color: #fff; }
.btn-g { background: linear-gradient(135deg, var(--green), var(--green-d)); color: #fff; box-shadow: 0 3px 12px rgba(0, 200, 150, .3); }
.btn-g:hover { transform: translateY(-1px); color: #fff; }
.btn-o { background: #fff; color: var(--ink); border: 1px solid #DDE3EC; }
.btn-o:hover { border-color: var(--blue); color: var(--blue); }
.btn-d { background: var(--red); color: #fff; }
.btn-d:hover { color: #fff; filter: brightness(1.06); }
.btn-sm { padding: 5px 10px; font-size: 11px; border-radius: 8px; }
.btn-sm .material-symbols-outlined { font-size: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 10px; }

.badge {
  display: inline-flex; align-items: center; gap: 3px; padding: 3px 9px;
  border-radius: 999px; font-size: 10px; font-weight: 700; white-space: nowrap;
}
.badge .material-symbols-outlined { font-size: 12px; }
.b-green { background: rgba(0, 200, 150, .14); color: var(--green-ink); }
.b-blue { background: rgba(26, 115, 232, .12); color: var(--blue); }
.b-amber { background: rgba(245, 158, 11, .15); color: var(--amber-ink); }
.b-red { background: rgba(229, 57, 53, .12); color: var(--red-ink); }
.b-gray { background: #EEF1F6; color: var(--muted); }
.b-purple { background: rgba(139, 92, 246, .13); color: #6D28D9; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: #fff; border: 1px solid #DDE3EC; color: #4A5568;
  cursor: pointer; white-space: nowrap; font-family: inherit; text-decoration: none;
}
.chip:hover { border-color: var(--blue); color: var(--blue); text-decoration: none; }
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }

.seg { display: flex; background: #EBEFF6; border-radius: 10px; padding: 3px; gap: 2px; }
.seg button, .seg a {
  flex: 1; padding: 7px 12px; font-size: 12px; font-weight: 700; border-radius: 8px; border: none;
  background: none; color: var(--muted); cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 5px; text-decoration: none;
}
.seg .material-symbols-outlined { font-size: 15px; }
.seg .on { background: #fff; color: var(--blue); box-shadow: 0 1px 4px rgba(16, 24, 40, .12); }

input, select, textarea {
  font-family: inherit; font-size: 13px; border: 1px solid #DDE3EC; border-radius: var(--r-sm);
  padding: 9px 12px; width: 100%; outline: none; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26, 115, 232, .13); }
input[type=checkbox] { width: auto; }
select { appearance: none; background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7894' d='M2 4l4 4 4-4z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
label.lbl {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); display: block; margin-bottom: 4px;
}
.field { display: block; }
.err { color: var(--red-ink); font-size: 11px; margin-top: 4px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
thead th {
  background: #EEF2F8; padding: 9px 11px; text-align: left; font-size: 9.5px; font-weight: 800;
  color: #4A5568; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
tbody td { padding: 9px 11px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tbody tr:hover { background: #F8FAFD; }
table input, table select { padding: 5px 8px; font-size: 11.5px; }

.stat { background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 14px; }
.stat h4 { font-family: inherit; font-size: 9.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 800; }
.stat .v { font-size: 24px; font-weight: 800; color: var(--dark); line-height: 1.15; margin-top: 2px; font-family: 'Syne', sans-serif; }
.edge-b { border-left: 4px solid var(--blue); }
.edge-g { border-left: 4px solid var(--green); }
.edge-a { border-left: 4px solid var(--amber); }
.edge-r { border-left: 4px solid var(--red); }

.info { background: linear-gradient(90deg, rgba(26, 115, 232, .09), rgba(26, 115, 232, .02)); border: 1px solid rgba(26, 115, 232, .2); border-radius: 11px; padding: 12px 14px; }
.info-g { background: linear-gradient(90deg, rgba(0, 200, 150, .1), rgba(0, 200, 150, .02)); border: 1px solid rgba(0, 200, 150, .25); border-radius: 11px; padding: 12px 14px; }
.info-r { background: rgba(229, 57, 53, .06); border: 1px solid rgba(229, 57, 53, .22); border-radius: 11px; padding: 12px 14px; }

.hscroll { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.hscroll::-webkit-scrollbar { display: none; }

.thumb {
  width: 46px; height: 46px; border-radius: 12px; background: #EEF3FB; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 21px; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

.hero { background: linear-gradient(135deg, var(--green), var(--blue-d)); padding: 22px 0 30px; color: #fff; }
.hero-ai { background: linear-gradient(135deg, var(--purple), var(--blue)); }
.hero-dark { background: linear-gradient(135deg, var(--dark), var(--dark-3)); }

.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty .material-symbols-outlined { font-size: 40px; color: #C9D0DC; }

.sep { height: 1px; background: var(--line-2); border: 0; margin: 12px 0; }

.menu-list { overflow: hidden; }
.menu-list .item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 13px 15px;
  border: none; border-bottom: 1px solid var(--line-2); background: none; font-family: inherit;
  font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer; text-align: left; text-decoration: none;
}
.menu-list .item:last-child { border-bottom: none; }
.menu-list .item:hover { background: #F8FAFD; text-decoration: none; }

/* ── mapa ── */
.map-shell { position: relative; height: calc(100dvh - var(--header-h) - var(--nav-h) - 118px); min-height: 340px; }
.map-canvas { position: absolute; inset: 0; border-radius: 0; background: #E8EFF7; }
.map-badge {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  display: flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, .95);
  border: 1px solid rgba(0, 200, 150, .35); border-radius: 999px; padding: 5px 12px;
  font-size: 10.5px; font-weight: 700; color: var(--green-ink); box-shadow: 0 3px 10px rgba(0, 0, 0, .12);
}
.map-sheet { position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 2; }
.map-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; color: var(--muted); }

.ping { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; position: relative; }
.ping::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; background: rgba(0, 200, 150, .5);
  animation: ping 2s infinite;
}
@keyframes ping { 0%, 100% { transform: scale(1); opacity: .65; } 50% { transform: scale(2.6); opacity: 0; } }
.glow { animation: gl 2.2s ease-in-out infinite; }
@keyframes gl {
  0%, 100% { box-shadow: 0 3px 12px rgba(26, 115, 232, .3), 0 0 0 0 rgba(26, 115, 232, .45); }
  50% { box-shadow: 0 7px 20px rgba(26, 115, 232, .45), 0 0 0 7px rgba(26, 115, 232, 0); }
}
@media (prefers-reduced-motion: reduce) { .glow, .ping::after { animation: none; } }

/* ── chat asistente ── */
.chat { display: flex; flex-direction: column; gap: 11px; padding: 16px 0; }
.bubble { max-width: 88%; padding: 10px 14px; font-size: 13px; line-height: 1.55; }
.bubble-u { align-self: flex-end; background: linear-gradient(135deg, var(--blue), var(--blue-d)); color: #fff; border-radius: 14px 14px 4px 14px; max-width: 82%; }
.bubble-b { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; box-shadow: var(--shadow); }
.bubble-b a { font-weight: 700; }
.typing span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); margin-right: 3px; animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }

/* ── toast ── */
#toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%);
  background: var(--dark); color: #fff; padding: 12px 22px; border-radius: 12px; font-size: 13px;
  font-weight: 600; z-index: 9999; opacity: 0; transition: opacity .28s; pointer-events: none;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45); border-left: 4px solid var(--green); max-width: 90vw;
}
#toast.on { opacity: 1; }
#toast.err { border-left-color: var(--red); }

/* ── modal ── */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 15, 30, .55); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: var(--r-lg); width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); max-height: 90dvh; overflow-y: auto; }
.modal-head { padding: 15px 18px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 10px; }
.modal-body { padding: 18px; }

/* ═══════════ backoffice (comercio + admin) ═══════════
   El alcance lo define como escritorio; abajo de 1024 px avisamos. */
.bo { display: flex; min-height: 100dvh; }
.bo-side {
  width: 232px; flex-shrink: 0; background: linear-gradient(180deg, var(--dark), var(--dark-2) 60%, var(--dark-3));
  color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh;
}
.bo-side-head { padding: 14px 15px; border-bottom: 1px solid rgba(255, 255, 255, .09); display: flex; align-items: center; gap: 9px; }
.bo-nav { flex: 1; padding: 6px 0; overflow-y: auto; }
.nav-i {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin: 1px 8px; border-radius: var(--r-sm);
  font-size: 12.5px; font-weight: 600; cursor: pointer; color: rgba(255, 255, 255, .66); border: none;
  background: none; width: calc(100% - 16px); font-family: inherit; text-align: left; transition: .15s; text-decoration: none;
}
.nav-i:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-i.on { background: linear-gradient(90deg, rgba(26, 115, 232, .35), rgba(0, 200, 150, .1)); color: #fff; box-shadow: inset 3px 0 0 var(--green); }
.nav-i .material-symbols-outlined { font-size: 18px; }
.nav-sep { font-size: 8.5px; text-transform: uppercase; letter-spacing: .13em; color: rgba(255, 255, 255, .34); padding: 12px 16px 4px; font-weight: 700; }
.bo-side-foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .09); display: flex; align-items: center; gap: 9px; }

.bo-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--cream); }
.bo-head {
  min-height: 56px; background: #fff; border-bottom: 1px solid var(--line); display: flex;
  align-items: center; justify-content: space-between; gap: 14px; padding: 8px 20px; flex-shrink: 0;
}
.bo-strip {
  background: linear-gradient(90deg, var(--dark), var(--dark-3)); color: #fff; padding: 6px 20px;
  font-size: 10.5px; font-weight: 600; display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
}
.bo-body { flex: 1; padding: 20px; }
.bo-narrow { display: none; }

@media (max-width: 1023px) {
  .bo-side, .bo-body, .bo-head, .bo-strip { display: none; }
  .bo-narrow { display: block; padding: 40px 20px; text-align: center; max-width: 460px; margin: 0 auto; }
}

/* ── responsive de la app ── */
@media (min-width: 900px) {
  .bnav { position: static; border-top: none; border-bottom: 1px solid var(--line); padding: 0; justify-content: center; gap: 4px; }
  .btab { flex: 0 0 auto; flex-direction: row; gap: 6px; font-size: 13px; padding: 14px 18px; border-radius: 0; border-bottom: 2px solid transparent; }
  .btab.on { border-bottom-color: var(--blue); }
  .app-main { padding-bottom: 30px; }
  #toast { bottom: 24px; }
  .map-shell { height: calc(100dvh - 300px); min-height: 460px; }
}

@media (max-width: 640px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  h1 { font-size: 19px; }
}
