/* PorDía — sistema visual.
   Reglas del documento (§9): botones grandes, lenguaje cotidiano, el valor
   ofertado visualmente prominente, fecha y hora antes que el texto secundario,
   chips para categorías y verificación, un botón principal por pantalla.
   Los colores salen del logo: azul = identidad y estructura, naranja = la
   acción y el dinero, verde = todo salió bien, rojo = alerta o destruir. */

:root {
  --brand: #1a56db;
  --brand-2: #0b3aa8;
  --navy: #0d2c66;
  --brand-ink: #ffffff;
  --brand-soft: #e9f1fe;
  --brand-line: #c6dcfb;

  --acento: #f97316;
  --acento-ink: #c2410c;
  --acento-soft: #fff3e6;
  --acento-line: #ffd9b3;

  --ok: #12894f;
  --ok-soft: #e6f6ee;
  --warn: #b7791f;
  --warn-soft: #fdf3e2;
  --bad: #d13438;
  --bad-soft: #fdecec;
  --info: #1f6fd0;
  --info-soft: #e8f1fd;

  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #16203a;
  --muted: #5b6379;
  --dim: #858c9e;
  --line: #e4e8f1;
  --line-2: #d3d9e6;

  --r: 14px;
  --r-lg: 20px;
  --sombra: 0 1px 2px rgba(13, 44, 102, .06), 0 6px 18px rgba(13, 44, 102, .06);
  --sombra-alta: 0 10px 40px rgba(13, 44, 102, .22);
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.03rem; }
p { margin: 0 0 .7rem; }
small { font-size: .82rem; }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 1rem; }
.center { text-align: center; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.grow { flex: 1; }
.row { display: flex; gap: .6rem; align-items: center; }
.row.wrap-row { flex-wrap: wrap; }
.between { display: flex; gap: .6rem; align-items: center; justify-content: space-between; }
.stack { display: grid; gap: .75rem; }
.hide { display: none !important; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------- cabecera -- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .inner {
  max-width: 640px; margin: 0 auto; padding: .65rem 1rem;
  display: flex; align-items: center; gap: .7rem; min-height: 56px;
}
.topbar h1 { font-size: 1.12rem; margin: 0; }
.topbar .sub { font-size: .78rem; color: var(--dim); }
.iconbtn {
  border: 0; background: transparent; color: var(--ink);
  width: 40px; height: 40px; border-radius: 12px; font-size: 1.15rem;
  display: grid; place-items: center; cursor: pointer; position: relative;
}
.iconbtn:active { background: var(--brand-soft); }
.punto {
  position: absolute; top: 6px; right: 6px; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff;
  font-size: .66rem; font-weight: 800; display: grid; place-items: center;
}

/* --------------------------------------------------------------- tarjeta -- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 1rem; margin-bottom: .85rem;
  box-shadow: var(--sombra);
}
.card.tight { padding: .8rem; }
.card.plano { box-shadow: none; }

/* -------------------------------------------------------------- botones --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  border-radius: var(--r); padding: .78rem 1.05rem;
  font: inherit; font-weight: 650; cursor: pointer;
  min-height: 48px; transition: transform .06s, filter .15s;
}
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: var(--brand-ink); border-color: transparent; }
.btn.accion { background: linear-gradient(135deg, #fb923c, var(--acento)); color: #fff; border-color: transparent; }
.btn.ok { background: var(--ok); color: #fff; border-color: transparent; }
.btn.danger { background: #fff; color: var(--bad); border-color: #f0c3c4; }
.btn.ghost { background: transparent; border-color: var(--line-2); }
.btn.block { display: flex; width: 100%; }
.btn.lg { min-height: 54px; font-size: 1.03rem; }
.btn.sm { min-height: 38px; padding: .4rem .7rem; font-size: .85rem; border-radius: 10px; }
.btn.link { border: 0; background: none; color: var(--brand); min-height: 0; padding: .25rem; }

/* ------------------------------------------------------------ formulario -- */
label.campo { display: block; margin-bottom: .85rem; }
label.campo > span.et {
  display: block; font-size: .84rem; font-weight: 650; color: var(--muted); margin-bottom: .3rem;
}
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line-2); border-radius: var(--r);
  padding: .78rem .85rem; min-height: 48px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.ayuda { font-size: .78rem; color: var(--dim); margin-top: .28rem; }
.error-campo { font-size: .8rem; color: var(--bad); margin-top: .28rem; }
fieldset { border: 0; margin: 0; padding: 0; }

/* --------------------------------------------------------------- chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  border: 1px solid var(--line-2); background: #fff; color: var(--muted);
  border-radius: 999px; padding: .34rem .7rem; font-size: .82rem; font-weight: 600;
  cursor: pointer; user-select: none;
}
.chip.on { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand); }
.chip.estatico { cursor: default; }
.chip.ok { background: var(--ok-soft); border-color: #bfe5d1; color: var(--ok); }
.chip.warn { background: var(--warn-soft); border-color: #f0dcb4; color: var(--warn); }
.chip.bad { background: var(--bad-soft); border-color: #f2c8c9; color: var(--bad); }
.chip.info { background: var(--info-soft); border-color: #c7ddf7; color: var(--info); }
.chip.brand { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand); }
.chip.gris { background: #f1f0f5; }

.scroll-x {
  display: flex; gap: .45rem; overflow-x: auto; padding-bottom: .3rem;
  scrollbar-width: none; -ms-overflow-style: none;
}
.scroll-x::-webkit-scrollbar { display: none; }
.scroll-x > * { flex: none; }

/* -------------------------------------------------------- tarjeta oferta -- */
.oferta {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: .9rem; margin-bottom: .7rem; box-shadow: var(--sombra); cursor: pointer;
  display: block; width: 100%; text-align: left; font: inherit; color: inherit;
}
.oferta:active { transform: scale(.995); }
.oferta.destacada { border-color: var(--brand-line); box-shadow: 0 0 0 2px var(--brand-soft), var(--sombra); }
.oferta .titulo { font-weight: 750; font-size: 1.02rem; margin: .15rem 0 .2rem; }
.oferta .cuando { font-size: .85rem; color: var(--muted); font-weight: 600; }
.oferta .pago {
  font-size: 1.32rem; font-weight: 850; color: var(--acento-ink); letter-spacing: -.02em;
}
.oferta .pago small { font-size: .74rem; font-weight: 650; color: var(--muted); margin-left: .2rem; }
.oferta .pie { display: flex; align-items: center; gap: .45rem; margin-top: .55rem; font-size: .8rem; color: var(--dim); flex-wrap: wrap; }
.oferta .cat { font-size: 1.4rem; line-height: 1; }

.estrella { color: #e8a317; }

/* ------------------------------------------------------------- avatares -- */
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 800; font-size: .95rem;
  object-fit: cover; overflow: hidden;
}
.avatar.lg { width: 72px; height: 72px; font-size: 1.5rem; }
.avatar.sm { width: 32px; height: 32px; font-size: .78rem; }

/* -------------------------------------------------------------- pasos ----- */
.pasos { display: flex; gap: .35rem; margin-bottom: 1rem; }
.pasos .p { flex: 1; height: 5px; border-radius: 3px; background: var(--line-2); }
.pasos .p.on { background: var(--brand); }

.linea-tiempo { display: grid; gap: .1rem; }
.linea-tiempo .h { display: flex; gap: .6rem; align-items: flex-start; }
.linea-tiempo .bolita {
  width: 13px; height: 13px; border-radius: 50%; background: var(--line-2);
  margin-top: .32rem; flex: none; position: relative;
}
.linea-tiempo .h.on .bolita { background: var(--ok); }
.linea-tiempo .h:not(:last-child) .bolita::after {
  content: ''; position: absolute; left: 50%; top: 13px; width: 2px; height: 26px;
  background: var(--line-2); transform: translateX(-50%);
}
.linea-tiempo .h.on:not(:last-child) .bolita::after { background: var(--ok); }
.linea-tiempo .t { padding-bottom: 1rem; font-size: .9rem; }
.linea-tiempo .t b { display: block; }
.linea-tiempo .t span { color: var(--dim); font-size: .8rem; }

/* ---------------------------------------------------------------- chat ---- */
.chat-lista { display: flex; flex-direction: column; gap: .45rem; padding-bottom: 1rem; }
.burbuja {
  max-width: 82%; padding: .6rem .8rem; border-radius: 16px;
  background: #fff; border: 1px solid var(--line); font-size: .95rem;
}
.burbuja.mia { align-self: flex-end; background: var(--brand); color: #fff; border-color: transparent; }
.burbuja .hora { display: block; font-size: .68rem; opacity: .7; margin-top: .2rem; }
.chat-barra {
  position: sticky; bottom: 0; background: rgba(255, 255, 255, .95); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding: .6rem 0 calc(.6rem + var(--safe-b));
  display: flex; gap: .5rem;
}

/* ----------------------------------------------------------- navegación --- */
main { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 1.2rem); }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.nav .inner { max-width: 640px; margin: 0 auto; display: flex; }
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; height: var(--nav-h); color: var(--dim); font-size: .68rem; font-weight: 650;
  position: relative;
}
.nav a .ic { font-size: 1.25rem; line-height: 1; }
.nav a.on { color: var(--brand); }
.nav a.publicar .ic {
  width: 46px; height: 46px; margin-top: -16px; border-radius: 16px;
  background: linear-gradient(135deg, #fb923c, var(--acento)); color: #fff;
  display: grid; place-items: center; font-size: 1.5rem;
  box-shadow: 0 6px 16px rgba(249, 115, 22, .42);
}
.nav a.publicar { color: var(--acento-ink); }
.nav .punto { top: 6px; right: calc(50% - 20px); }

/* ------------------------------------------------------------- hoja ------- */
.sheet-bg {
  position: fixed; inset: 0; z-index: 60; background: rgba(20, 16, 34, .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease-out;
}
.sheet {
  background: var(--card); width: 100%; max-width: 640px;
  border-radius: 22px 22px 0 0; padding: .6rem 1.1rem calc(1.3rem + var(--safe-b));
  max-height: 92vh; overflow-y: auto; box-shadow: var(--sombra-alta);
  animation: subir .2s cubic-bezier(.2, .8, .3, 1);
}
.sheet .handle { width: 40px; height: 4px; border-radius: 3px; background: var(--line-2); margin: .3rem auto 1rem; }
@keyframes subir { from { transform: translateY(18px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ------------------------------------------------------------- toasts ----- */
#toasts {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px);
  z-index: 90; display: grid; gap: .4rem; width: min(92vw, 460px);
}
.toast {
  background: #241d38; color: #fff; padding: .75rem .95rem; border-radius: 12px;
  font-size: .9rem; box-shadow: var(--sombra-alta);
}
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* -------------------------------------------------------------- varios ---- */
.vacio { text-align: center; padding: 2.4rem 1rem; color: var(--dim); }
.vacio .e { font-size: 2.6rem; display: block; margin-bottom: .5rem; }

.aviso {
  border-radius: var(--r); padding: .75rem .85rem; font-size: .87rem;
  border: 1px solid var(--line-2); background: #fff; margin-bottom: .8rem;
}
.aviso.info { background: var(--info-soft); border-color: #c7ddf7; color: #164a8c; }
.aviso.warn { background: var(--warn-soft); border-color: #f0dcb4; color: #7c5410; }
.aviso.bad { background: var(--bad-soft); border-color: #f2c8c9; color: #8f2326; }
.aviso.ok { background: var(--ok-soft); border-color: #bfe5d1; color: #0c6339; }

.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 650; text-align: right; }

.sep { height: 1px; background: var(--line); margin: .9rem 0; }

.skel { background: linear-gradient(90deg, #eeecf3, #f7f6fa, #eeecf3); background-size: 200% 100%; animation: sk 1.1s infinite; border-radius: var(--r); }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.estrellas-input { display: flex; gap: .25rem; }
.estrellas-input button {
  border: 0; background: none; font-size: 1.7rem; cursor: pointer; padding: 0 .1rem;
  color: var(--line-2); line-height: 1;
}
.estrellas-input button.on { color: #e8a317; }

.tabla { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tabla th, .tabla td { padding: .55rem .5rem; text-align: left; border-bottom: 1px solid var(--line); }
.tabla th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); font-weight: 700; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla-scroll { overflow-x: auto; }

.metricas { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; }
.metrica { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem; }
.metrica .n { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.metrica .l { font-size: .76rem; color: var(--muted); }

.barras { display: flex; align-items: flex-end; gap: 4px; height: 72px; }
.barras .b { flex: 1; max-width: 44px; background: var(--brand-soft); border-radius: 4px 4px 0 0; min-height: 3px; }
.barras .b.hoy { background: var(--brand); }

/* Logotipo en texto: mismo juego del logo (Por en azul, Día en naranja) para
   las pantallas donde cargar la imagen sería un peso de más. */
.marca { display: inline-flex; align-items: baseline; gap: .02em; font-weight: 850; letter-spacing: -.03em; }
.marca .por { color: var(--navy); }
.marca .dia { color: var(--acento); }
.marca.claro .por { color: #fff; }
.marca.grande { font-size: 2.1rem; }
.logo-img { display: block; max-width: 100%; height: auto; }

@media (min-width: 720px) {
  .nav { border-top: 1px solid var(--line); }
  .card { padding: 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
