/* Design system Vertex — azul #1A6FFF, claro/oscuro, tipografia de sistema. */
:root {
  --brand: #1A6FFF;
  --brand-600: #155ee0;
  --on-brand: #FFFFFF;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f0f3f9;
  --text: #0e1726;
  --muted: #5b6678;
  --border: #e3e8f0;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
  --font: 'Inter', 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
[data-tema="dark"] {
  --bg: #0b0f17;
  --surface: #121826;
  --surface-2: #1a2233;
  --text: #eaf0fa;
  --muted: #94a2b8;
  --border: #232c3d;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--brand); font-weight: 800; letter-spacing: -.02em; }
.brand .name { color: var(--text); font-size: 18px; }
.brand .name b { color: var(--brand); }
.spacer { flex: 1; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 26px 20px 60px; }

/* botones */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
  cursor: pointer; transition: .15s ease; font-family: inherit;
}
.btn:hover { border-color: var(--brand); }
.btn-primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-600); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* inputs */
label.field { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input, textarea, select {
  width: 100%; font-family: inherit; font-size: 14.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; outline: none; transition: .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
textarea { resize: vertical; min-height: 120px; line-height: 1.55; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 20px; }
.grid { display: grid; gap: 14px; }
@media (min-width: 680px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: 1fr 1fr 1fr; } }

/* buscador */
.hero h1 { font-size: 26px; letter-spacing: -.03em; margin: 0 0 4px; }
.hero p { color: var(--muted); margin: 0 0 18px; }
.search-row { display: flex; gap: 10px; }
.search-row input { font-size: 16px; }
@media (max-width: 560px) { .search-row { flex-direction: column; } }

/* resultado proveedor */
.prov {
  display: flex; gap: 14px; padding: 16px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); position: relative;
}
.prov.best { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
.prov .thumb { width: 56px; height: 56px; border-radius: 10px; background: var(--surface-2); flex: 0 0 auto; object-fit: cover; display: grid; place-items: center; color: var(--muted); }
.prov .body { flex: 1; min-width: 0; }
.prov .title { font-weight: 700; font-size: 15px; margin: 0; }
.prov .src { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.prov .price { font-size: 22px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.prov .price small { font-size: 12px; color: var(--muted); font-weight: 600; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge.best { background: var(--brand); color: var(--on-brand); }
.badge.retail { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.badge.mayorista { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge.no { background: var(--surface-2); color: var(--muted); }

.contacts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 5px 10px; border-radius: 8px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.chip:hover { border-color: var(--brand); }

.row-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* mensaje generado */
.msg { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 12px; }
.msg .tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.msg .tab { font-size: 12.5px; font-weight: 600; padding: 5px 11px; border-radius: 8px; cursor: pointer; color: var(--muted); background: var(--surface-2); border: 1px solid transparent; }
.msg .tab.active { color: var(--brand); border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.msg pre { white-space: pre-wrap; font-family: inherit; font-size: 13.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin: 0; }

/* toast */
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); animation: up .2s ease; }
@keyframes up { from { opacity: 0; transform: translateY(8px); } }

.muted { color: var(--muted); }
.center { text-align: center; }
.hide { display: none !important; }
.spin { width: 18px; height: 18px; border: 2.5px solid color-mix(in srgb, var(--brand) 30%, transparent); border-top-color: var(--brand); border-radius: 50%; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* login */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { justify-content: center; margin-bottom: 18px; }
.footer-credito { text-align: center; color: var(--muted); font-size: 12px; margin-top: 26px; }

/* nav */
.nav { display: flex; gap: 4px; }
.nav-btn.active { color: var(--brand); background: var(--surface-2); }

/* saldo / plan */
.saldo { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 16px; margin-bottom: 16px; font-size: 13px; }
.bar { width: 120px; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); }

/* controles de resultados */
select.mini { width: auto; padding: 6px 10px; font-size: 13px; }
.chiptgl.on { border-color: var(--brand); color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.cmp { font-size: 12px; color: var(--muted); display: inline-flex; gap: 5px; align-items: center; cursor: pointer; }
.cmp input { width: auto; }
.cmp-tbl { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.cmp-tbl th, .cmp-tbl td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }

/* skeletons */
.prov.skel { pointer-events: none; }
.prov.skel .thumb, .prov.skel .ln { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: pulse 1.2s infinite; }
.prov.skel .ln { height: 12px; border-radius: 6px; margin: 8px 0; }
.ln.w60 { width: 60%; } .ln.w40 { width: 40%; } .ln.w30 { width: 30%; }
@keyframes pulse { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* kpis */
.kpi-n { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.kpi .muted { font-size: 12.5px; }

/* responsive (#18) */
@media (max-width: 760px) {
  /* La barra superior envuelve: marca + acciones arriba, nav como tab-bar scrollable abajo. */
  .topbar { flex-wrap: wrap; gap: 10px 12px; }
  .brand { order: 1; }
  .spacer { order: 2; flex: 1; }
  #quien { order: 3; display: none; }
  #btn-tema { order: 4; }
  #btn-logout { order: 5; }
  .nav { order: 6; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .nav::-webkit-scrollbar { height: 0; }
  .nav .nav-btn { flex: 0 0 auto; white-space: nowrap; }
}
@media (max-width: 560px) {
  .prov { flex-wrap: wrap; }
  .prov .price { width: 100%; text-align: left; margin-top: 6px; }
  .search-row { flex-direction: column; }
}
/* Red de seguridad: ningun elemento genera scroll horizontal de pagina en movil. */
@media (max-width: 560px) { html, body { max-width: 100%; overflow-x: clip; } }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.warn { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); padding: 5px 9px; border-radius: 8px; }

/* correo multi-cuenta */
.cuenta-chip.on, .sub.on { border-color: var(--brand); color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.msg-row { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: baseline; }
.msg-row:hover { background: var(--surface-2); }
.msg-de { width: 30%; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-as { flex: 1; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-fe { font-size: 11.5px; white-space: nowrap; }
@media (max-width: 560px) { .msg-de { width: 100%; } .msg-row { flex-wrap: wrap; } }

/* command palette (#24) */
.paleta-ov { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 60; display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; }
.paleta { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: 90%; max-width: 480px; box-shadow: var(--shadow); overflow: hidden; }
.paleta input { border: none; border-bottom: 1px solid var(--border); border-radius: 0; padding: 14px 16px; font-size: 15px; }
.paleta input:focus { box-shadow: none; }
.paleta-item { padding: 11px 16px; cursor: pointer; font-size: 14px; }
.paleta-item:hover { background: var(--surface-2); color: var(--brand); }

/* kanban (#22) */
.kanban { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.kan-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px; min-height: 80px; }
.kan-h { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .03em; }
.kan-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 8px; }
@media (max-width: 640px) { .kanban { grid-template-columns: 1fr; } }
