/* Panel de Cajafy: CSS propio, sin compilar (hosting compartido). Mismos colores que la app de escritorio. */

:root {
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --ink: #0f172a;
  --muted: #566277;
  --line: #d5dce6;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --bg: #eef1f5;
  --brand: #0b5fe6;
  --brand-ink: #ffffff;
  --ok: #157f3b;
  --ok-soft: #dcf5e4;
  --warn: #a15c07;
  --warn-soft: #fdf0d2;
  --danger: #b42318;
  --danger-soft: #fde4e1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 15px/1.45 var(--font);
  color: var(--ink);
  background: var(--bg);
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
}

h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.num,
.mono {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: Consolas, 'Courier New', monospace;
}

/* ---------- Encabezado ---------- */

/*
 * Envuelve siempre, no solo en el teléfono: en una tableta las ocho secciones del panel del cliente
 * no caben en un renglón, y sin esto estiraban la página entera.
 */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 24px;
  padding: 10px 24px;
  color: #e6ebf2;
  background: var(--ink);
}

.top__brand {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
}

.top__brand span {
  color: #7fb0ff;
}

.top__brand small {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #8fa0ba;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.top__brand:hover {
  text-decoration: none;
}

.top__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.top__nav a {
  padding: 7px 14px;
  color: #b7c2d3;
  border-radius: 8px;
}

.top__nav a:hover {
  color: #fff;
  text-decoration: none;
}

.top__nav a.is-active {
  color: #fff;
  background: #24324d;
}

.top__business {
  font-size: 15px;
  color: #b7c2d3;
}

.top__user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  color: #d6deea;
}

/* ---------- Página ---------- */

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 24px 60px;
}

.page__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.crumbs {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.actions--end {
  justify-content: flex-end;
}

.card {
  padding: 18px 20px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.card__title {
  margin-bottom: 10px;
}

.stack > * + * {
  margin-top: 14px;
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px 18px;
}

.inline {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.inline.wrap {
  flex-wrap: wrap;
}

/* ---------- Formularios ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.input {
  min-width: 0;
  padding: 9px 11px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 8px;
}

.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(11, 95, 230, 0.15);
}

.input--small {
  padding: 6px 9px;
  font-size: 13px;
}

.input--tiny {
  width: 72px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hint {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 8px;
}

.btn:hover {
  text-decoration: none;
  background: var(--surface-2);
}

.btn--primary {
  color: var(--brand-ink);
  background: var(--brand);
  border-color: var(--brand);
}

.btn--primary:hover {
  background: #094fd6;
}

.btn--danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.btn--danger:hover {
  background: #911c12;
}

.btn--ghost {
  color: #d6deea;
  background: #24324d;
  border-color: #24324d;
}

.btn--ghost:hover {
  color: #fff;
  background: #2f416a;
}

.btn--small {
  padding: 5px 10px;
  font-size: 13px;
}

.btn--block {
  justify-content: center;
  width: 100%;
}

.btn[aria-disabled='true'] {
  opacity: 0.5;
  pointer-events: none;
}

/* ---------- Avisos ---------- */

.flash {
  padding: 10px 14px;
  margin-bottom: 14px;
  border-radius: 9px;
  border: 1px solid transparent;
}

.flash--ok {
  color: #0d4d24;
  background: var(--ok-soft);
  border-color: #a9dfb9;
}

.flash--bad {
  color: #6b140d;
  background: var(--danger-soft);
  border-color: #efb4ae;
}

.flash__list {
  margin: 0;
  padding-left: 18px;
}

/* ---------- Tablas ---------- */

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.table th {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--muted);
  text-transform: uppercase;
}

.table th.num,
.table td.num {
  text-align: right;
}

.table--compact th,
.table--compact td {
  padding: 6px 8px;
  font-size: 14px;
}

.table tr.is-revoked td,
.table tr.is-muted td {
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  border-radius: 999px;
}

.badge--ok {
  color: var(--ok);
  background: var(--ok-soft);
}

.badge--warn {
  color: var(--warn);
  background: var(--warn-soft);
}

.badge--bad {
  color: var(--danger);
  background: var(--danger-soft);
}

.badge--muted {
  color: var(--muted);
  background: var(--surface-2);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.pager__info {
  color: var(--muted);
}

/* ---------- Inicio ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.tile {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.tile__n {
  display: block;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
}

.tile__l {
  font-size: 13px;
  color: var(--muted);
}

.tile--warn .tile__n {
  color: var(--warn);
}

/* ---------- Ficha del cliente ---------- */

.sub {
  padding: 12px 14px;
  margin-top: 8px;
  background: var(--surface-2);
  border-radius: 10px;
}

.sub__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 10px;
}

.lic__key {
  padding: 4px 8px;
  font-size: 15px;
  letter-spacing: 1px;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 6px;
}

.sub__edit {
  margin-top: 10px;
}

.sub__edit summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}

.sub__edit form {
  margin-top: 10px;
}

/* ---------- Acceso ---------- */

.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.auth__card {
  width: min(400px, 92vw);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

/* El logotipo de verdad; antes era el nombre escrito a mano con un <span> de color. */
.auth__brand {
  display: inline-block;
}

.auth__brand img {
  display: block;
  height: 38px;
  width: auto;
}

.auth__title {
  margin: 4px 0 2px;
  font-size: 18px;
}


/* Dos columnas de ancho distinto: la lista manda y el formulario la acompana (departamentos, clientes). */
.grid2--wide {
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr);
  align-items: start;
}

.grid2--wide > .card {
  margin-bottom: 0;
}

/* El dato grande de una tarjeta de resumen ("te deben en total"). */
.card--stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.stat__value {
  font-size: 26px;
  font-variant-numeric: tabular-nums;
}

/* Lo que ya paso de su limite de credito: se ve, no se explica. */
.is-over {
  color: var(--danger);
}

@media (max-width: 980px) {
  .grid2--wide {
    grid-template-columns: 1fr;
  }
}

/* ---------- Reportes y existencias (sección 49) ---------- */

.subnav {
  display: flex;
  gap: 4px;
  margin: 0 0 14px;
  border-bottom: 1px solid #d5dce6;
}

.subnav a {
  padding: 8px 14px;
  color: inherit;
  text-decoration: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  font-weight: 600;
}

.subnav a.is-active {
  border-bottom-color: currentColor;
}

.filters {
  margin-bottom: 4px;
}

.neg {
  color: #b42318;
}

.pos {
  color: #157f3b;
}

/* Una tabla ancha se recorre de lado DENTRO de su tarjeta, sin estirar la página. */
.table-scroll {
  overflow-x: auto;
}

tr.is-selected td {
  background: #dbe7ff;
}

/* ---------- En el teléfono ---------- */

/*
 * El problema que arregla este bloque: una tabla de muchas columnas estiraba la página entera, y en el
 * teléfono la barra oscura de arriba se cortaba a media pantalla y todo quedaba apretado a la izquierda.
 * Ahora la que se recorre de lado es la tabla, no la página.
 */
@media (max-width: 720px) {
  .top {
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 10px 14px;
  }

  /* Arriba el nombre y quién entró; abajo las secciones, que se recorren de lado si no caben. */
  .top__brand {
    order: 1;
  }

  .top__user {
    order: 2;
  }

  .top__business {
    order: 3;
    flex-basis: 100%;
  }

  /* En el teléfono se recorren de lado en un solo renglón: envueltas ocuparían media pantalla. */
  .top__nav {
    order: 4;
    flex-basis: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .top__nav::-webkit-scrollbar {
    display: none;
  }

  .top__nav a {
    flex: 0 0 auto;
    padding: 7px 11px;
  }

  .page {
    padding: 16px 14px 48px;
  }

  .page__head {
    flex-direction: column;
  }

  .card {
    padding: 14px;
  }

  /* Los renglones de controles (el filtro de fechas y sucursal) se acomodan en varias líneas. */
  .inline {
    flex-wrap: wrap;
  }

  .filters .field {
    flex: 1 1 140px;
  }

  .tiles {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  /*
   * Sin esto la tabla seguiría cabiendo a la fuerza en la pantalla: cada celda se partiría en tres
   * renglones ("Pago único (edición local)") y no habría nada que recorrer. Al no partir el texto, la
   * tabla crece a lo que de verdad mide y se recorre de lado.
   */
  .table-scroll th,
  .table-scroll td {
    white-space: nowrap;
  }

  .table th,
  .table td {
    padding: 8px;
  }

  /*
   * La tabla que no cabe se apila: cada renglón es una tarjeta con sus datos etiquetados. Quién se
   * apila lo decide panel.js, que mide cuáles no caben.
   */
  .table--stack thead {
    display: none;
  }

  .table--stack,
  .table--stack tbody,
  .table--stack tr,
  .table--stack td {
    display: block;
  }

  .table--stack tr {
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
  }

  .table--stack tr:last-child {
    border-bottom: 0;
  }

  /*
   * La etiqueta va flotando a la izquierda y el valor fluye a su derecha. Con flex no servía: cada
   * pedazo de la celda ("Coca-Cola 600 ml" y su clave) se habría ido a una esquina distinta.
   */
  .table--stack td {
    padding: 3px 0;
    text-align: right;
    white-space: normal;
    border: 0;
  }

  .table--stack td::before {
    content: attr(data-label);
    float: left;
    max-width: 45%;
    margin-right: 14px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--muted);
    text-align: left;
    text-transform: uppercase;
  }

  /* La columna sin título (el botón de Editar) y las celdas vacías no gastan un renglón. */
  .table--stack td[data-label='']::before {
    content: none;
  }

  .table--stack td:empty {
    display: none;
  }

  /* Las pestañas de reportes, igual que las secciones de arriba. */
  .subnav {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .subnav::-webkit-scrollbar {
    display: none;
  }

  .subnav a {
    flex: 0 0 auto;
    padding: 8px 11px;
  }
}
