/* =====================================================================
   Pulso · hoja de estilos única
   Sistema chico a propósito: tokens, tipografía, 6 componentes.
   ===================================================================== */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #98a2b3;
  --brand: #1b5e4b;
  --brand-soft: #e8f4ef;
  --pos: #15803d;
  --pos-soft: #ecfdf3;
  --neg: #b42318;
  --neg-soft: #fef3f2;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(16,24,40,.05);
  --shadow-lg: 0 8px 24px rgba(16,24,40,.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 1em; }
small, .muted { color: var(--ink-2); }
.tiny { font-size: 12px; color: var(--ink-3); }

/* ------------------------------------------------------------ estructura */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 22px; min-height: 58px; flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: -.02em; text-decoration: none; color: var(--ink); }
.brand span { color: var(--brand); }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  padding: 7px 11px; border-radius: 8px; text-decoration: none;
  color: var(--ink-2); font-size: 14px; font-weight: 500;
}
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.subnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 58px; z-index: 19;
}
.subnav-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 20px;
  display: flex; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.subnav a {
  padding: 11px 13px; text-decoration: none; white-space: nowrap;
  color: var(--ink-2); font-size: 13.5px; font-weight: 500;
  border-bottom: 2px solid transparent;
}
.subnav a:hover { color: var(--ink); }
.subnav a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 20px 80px; }
.wrap-narrow { max-width: 640px; margin: 0 auto; padding: 40px 20px 80px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
/* El selector de fecha hereda width:100% de los inputs y, dentro de una
   barra de acciones, empuja todo lo demás a una segunda línea. */
.page-head input[type=date] { width: auto; }

/* ------------------------------------------------------------- tarjetas */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.start { align-items: start; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* --------------------------------------------------------------- kpis */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.kpi .label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; }
.kpi .value { font-size: 25px; font-weight: 680; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .foot { font-size: 12px; color: var(--ink-2); margin-top: 5px; }
.kpi.accent { background: var(--brand); border-color: var(--brand); color: #fff; }
.kpi.accent .label, .kpi.accent .foot { color: rgba(255,255,255,.72); }

.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* -------------------------------------------------------------- tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 650; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

/* --------------------------------------------------------------- chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--bg); color: var(--ink-2); white-space: nowrap;
}
.chip.ok { background: var(--pos-soft); color: var(--pos); }
.chip.bad { background: var(--neg-soft); color: var(--neg); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.info { background: var(--brand-soft); color: var(--brand); }

/* ------------------------------------------------------------ controles */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; font-family: inherit;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--bg); filter: none; }
.btn.danger { background: var(--surface); color: var(--neg); border-color: #fda29b; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong);
  border-radius: 9px; font: inherit; font-size: 14px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input.compact { padding: 6px 8px; font-size: 13px; max-width: 130px; }
.field { margin-bottom: 14px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.checkline { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.checkline input { width: auto; }

/* --------------------------------------------------------------- avisos */
.flash { padding: 12px 15px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.flash.success { background: var(--pos-soft); color: var(--pos); }
.flash.error { background: var(--neg-soft); color: var(--neg); }
.flash.info { background: var(--brand-soft); color: var(--brand); }

.notice {
  border-left: 3px solid var(--warn); background: var(--warn-soft);
  padding: 13px 16px; border-radius: 0 10px 10px 0; font-size: 14px; margin-bottom: 16px;
}
.notice.info { border-color: var(--brand); background: var(--brand-soft); }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty h3 { color: var(--ink); }

/* ---------------------------------------------------------- onboarding */
.step { display: flex; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--border); }
.step:last-child { border-bottom: none; }
.step-num {
  flex: 0 0 30px; height: 30px; border-radius: 50%; background: var(--bg);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--ink-3);
}
.step.done .step-num { background: var(--pos-soft); color: var(--pos); }
.step.current .step-num { background: var(--brand); color: #fff; }
.step-body { flex: 1; }
.step-body h3 { margin-bottom: 3px; }

/* ------------------------------------------------------------- barritas */
.bar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); }

.spark { display: flex; align-items: flex-end; gap: 3px; height: 54px; }
.spark i { flex: 1; background: var(--brand-soft); border-radius: 2px 2px 0 0; min-height: 2px; }
.spark i.peak { background: var(--brand); }

/* --------------------------------------------------------------- prosa */
.prose { font-size: 15px; line-height: 1.65; }
.prose h3 { margin: 22px 0 8px; font-size: 16px; }
.prose h4 { margin: 18px 0 6px; font-size: 14.5px; color: var(--ink-2); }
.prose ul { margin: 0 0 12px; padding-left: 20px; }
.prose li { margin-bottom: 4px; }

/* =====================================================================
   Panel diario
   ===================================================================== */

/* ------------------------------------------------- signo de ayuda ("?") */
/* Sin JavaScript: se abre con el mouse y también con el teclado (Tab),
   que es lo que lo hace usable en un lector de pantalla. */
.help {
  position: relative; display: inline-flex; vertical-align: middle;
  margin-left: 5px; cursor: help; outline: none;
}
.help > b {
  display: grid; place-items: center;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--border); color: var(--ink-2);
  font-size: 10px; font-weight: 700; line-height: 1;
}
.help:hover > b, .help:focus > b { background: var(--brand); color: #fff; }
.help > em {
  display: none; position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  width: max-content; max-width: min(280px, 70vw);
  background: var(--ink); color: #fff;
  padding: 9px 11px; border-radius: 9px;
  font: 400 12.5px/1.45 inherit; font-style: normal;
  text-transform: none; letter-spacing: 0;
  box-shadow: var(--shadow-lg); z-index: 40; white-space: normal;
}
.help.end > em { left: auto; right: 0; transform: none; }
.help:hover > em, .help:focus > em { display: block; }
.kpi.accent .help > b { background: rgba(255,255,255,.28); color: #fff; }

/* --------------------------------------------------- variación vs. semana */
.delta { font-weight: 650; font-size: 12px; }
.delta.up { color: var(--pos); }
.delta.down { color: var(--neg); }

/* ------------------------------------------------------- números chicos */
.mini { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.mini .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 650; }
.mini .v { font-size: 19px; font-weight: 680; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------- barra de carga */
/* Se dispara en el clic, no cuando llega la respuesta: lo único que tiene
   que lograr es que la espera no se sienta como una pantalla colgada. */
#nprog {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--brand); z-index: 60; opacity: 0;
  transition: width .25s ease, opacity .25s ease;
}
#nprog.go { width: 70%; opacity: 1; }
#nprog.go.slow { width: 92%; transition: width 6s ease; }
#nprog.done { width: 100%; opacity: 0; transition: width .15s ease, opacity .3s ease .15s; }

/* --------------------------------------------- estado de sincronización */
/* Ocupa el ancho abajo de todo: hay lugar para decir qué se está trayendo,
   cuánto falta y qué terminó. Un cartelito chico no alcanza para eso. */
.loadbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--ink); color: #fff;
  box-shadow: 0 -8px 24px rgba(16,24,40,.18);
}
.loadbar-inner { max-width: 1180px; margin: 0 auto; padding: 13px 20px 15px; }
.loadbar-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.loadbar-head .t { font-size: 14px; font-weight: 650; }
.loadbar-head .n { color: rgba(255,255,255,.65); }
.loadbar .spinner { border-color: rgba(255,255,255,.3); border-top-color: #fff; }
.loadbar .spinner[hidden] { display: none; }

.loadbar-track {
  height: 4px; border-radius: 999px; margin-top: 10px;
  background: rgba(255,255,255,.18); overflow: hidden;
}
.loadbar-track > i {
  display: block; height: 100%; width: 0;
  background: #fff; border-radius: 999px;
  transition: width .5s ease;
}

.loadbar-log { list-style: none; margin: 9px 0 0; padding: 0; display: grid; gap: 3px; }
.loadbar-log li { font-size: 12px; color: rgba(255,255,255,.72); font-variant-numeric: tabular-nums; }
.loadbar-log li.bad { color: #fda29b; }

.loadbar.bad { background: var(--neg); }
.loadbar.bad .loadbar-track > i { background: #fff; }

/* Que la barra no tape el final de la página mientras está abierta. */
body:has(.loadbar:not([hidden])) .wrap { padding-bottom: 190px; }

@media (max-width: 620px) {
  .loadbar-inner { padding: 11px 14px 13px; }
  .loadbar-log li:not(:last-child) { display: none; }
}

button[data-busy] { opacity: .6; }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  #nprog { transition: opacity .2s ease; }
}

/* ------------------------------------------------- cortes con sus buckets */
/* Los buckets se muestran SIEMPRE, también en cero: "Mercado Pago · cuotas:
   0 pedidos" es información, y que la fila desaparezca rompe la lectura de
   un día al otro. Los que están en cero quedan atenuados. */
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.tile {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; background: var(--surface);
}
.tile .t { font-size: 12px; color: var(--ink-2); font-weight: 600; line-height: 1.35; }
.tile .v { font-size: 21px; font-weight: 680; margin-top: 5px; font-variant-numeric: tabular-nums; }
.tile .v span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.tile.zero { background: var(--bg); }
.tile.zero .v, .tile.zero .t { color: var(--ink-3); }

/* ----------------------------------------------- celda de pedido auditable */
.ordercell { display: flex; flex-direction: column; gap: 1px; }
.ordercell .n { font-weight: 600; font-variant-numeric: tabular-nums; }
.ordercell a { font-size: 11.5px; text-decoration: none; }
.ordercell a:hover { text-decoration: underline; }

td.rank, th.rank { width: 30px; color: var(--ink-3); font-weight: 700; font-size: 12px; text-align: center; }

/* ------------------------------------------------ automatizaciones de email */
.flow { border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 13px; margin-bottom: 8px; }
.flow-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.flow-name { font-weight: 620; font-size: 14px; margin-bottom: 2px; }
.flow-steps { margin-top: 9px; border-top: 1px solid var(--border); padding-top: 7px; display: grid; gap: 4px; }
.flow-step { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }

/* ------------------------------------------ avisos con su botón de arreglo */
.fixlist { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 7px; }
.fixlist li {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; font-size: 13px;
}

/* ---------------------------------------------------------- nota al pie */
.footnote {
  margin: 14px 0 0; font-size: 12px; line-height: 1.55; color: var(--ink-2);
  border-top: 1px solid var(--border); padding-top: 10px;
}

/* ----------------------------------------------------- filas especiales */
tr.sub td:first-child { padding-left: 26px; color: var(--ink-2); font-size: 13px; }
tr.total td { border-top: 2px solid var(--border-strong); border-bottom: none; font-size: 15px; }

/* --------------------------------------------------------- desplegables */
.disclose { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.disclose > summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--brand);
  list-style: none; padding: 4px 0;
}
.disclose > summary:hover { text-decoration: underline; }
.disclose > summary::-webkit-details-marker { display: none; }
.disclose > summary::before { content: '▸'; display: inline-block; width: 14px; }
.disclose[open] > summary::before { content: '▾'; }
.disclose.warn > summary { color: var(--warn); }

/* ------------------------------------------------------ lectura del día */
.card.read { margin-top: 16px; border-left: 3px solid var(--brand); }
.card.read .prose { color: var(--ink); }

/* -------------------------------------------------------- tira de semana */
.weekstrip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.weekstrip .day {
  display: block; text-decoration: none; color: inherit;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 12px;
}
.weekstrip .day:hover { border-color: var(--border-strong); background: #fafbfc; }
.weekstrip .day.current { border-color: var(--brand); background: var(--brand-soft); }
.weekstrip .d { font-size: 12px; font-weight: 650; color: var(--ink-2); }
.weekstrip .v { font-size: 15px; font-weight: 680; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.weekstrip .bar { margin-bottom: 6px; }

.sources { margin-top: 22px; line-height: 1.6; }

@media (max-width: 1100px) {
  .weekstrip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .weekstrip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wrap { padding: 18px 14px 60px; }
  h1 { font-size: 22px; }
  .help > em { position: fixed; left: 14px; right: 14px; bottom: 14px; top: auto; transform: none; max-width: none; width: auto; }
}

/* Dato que falta o que no es confiable. Distinto de un cero, a propósito. */
.warnx { color: var(--warn); font-weight: 600; }
.tiny.warnx { font-weight: 500; }
