:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --ink: #1b2430;
  --muted: #64707d;
  --line: #d5dbe3;
  --line-soft: #e8ecf1;
  --brand: #2a64ad;
  --brand-ink: #ffffff;
  --brand-soft: #d6e6f3;
  --sel: #cfe3f5;
  --ok: #1f7a4a;
  --ok-soft: #e1f3e8;
  --err: #b42318;
  --err-soft: #fde8e6;
  --warn: #9a6700;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); }
a { color: var(--brand); }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Barra superior */
.topbar {
  display: flex; align-items: center; gap: 20px; height: 42px; padding: 0 14px;
  background: var(--brand); color: var(--brand-ink);
}
.topbar .brand { color: inherit; font-weight: 700; text-decoration: none; letter-spacing: .5px; }
.topbar nav { display: flex; gap: 2px; }
.topbar nav a { color: inherit; text-decoration: none; padding: 6px 12px; border-radius: 4px; opacity: .85; }
.topbar nav a.on, .topbar nav a:hover { background: rgba(255,255,255,.16); opacity: 1; }
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.topbar .who form { margin: 0; }
.topbar .sep { opacity: .6; }

/* Boton "Opciones" de la barra: menu desplegable con <details>, sin JS */
.topbar .menu { position: relative; }
.topbar .menu summary {
  list-style: none; cursor: pointer; padding: 6px 12px; border-radius: 4px; opacity: .85;
}
.topbar .menu summary::-webkit-details-marker { display: none; }
.topbar .menu summary:hover, .topbar .menu[open] summary { background: rgba(255,255,255,.16); opacity: 1; }
.topbar .menu-list {
  position: absolute; top: calc(100% + 4px); right: 0; min-width: 180px; z-index: 20;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,.18); padding: 4px; display: flex; flex-direction: column;
}
.topbar .menu-list a { color: inherit; text-decoration: none; padding: 7px 10px; border-radius: 4px; }
.topbar .menu-list a:hover { background: var(--line-soft); }
button.link { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }

/* Mensajes */
.flashes { position: fixed; top: 50px; right: 14px; z-index: 50; display: grid; gap: 6px; }
.flash { padding: 10px 14px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.flash.error { background: var(--err-soft); border-color: #f4b8b1; color: var(--err); }
.flash.ok { background: var(--ok-soft); border-color: #a9dcbd; color: var(--ok); }

/* Controles */
input, select, textarea {
  font: inherit; color: inherit; background: #fff; border: 1px solid var(--line);
  border-radius: 4px; padding: 6px 8px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.btn {
  font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 4px; padding: 7px 14px; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn:hover { background: #f5f7fa; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--err); border-color: #f4b8b1; }
.btn.danger-solid { background: var(--err); border-color: var(--err); color: #fff; font-weight: 600; }
.btn.danger-solid:hover { filter: brightness(1.08); background: var(--err); }
.advertencia { background: var(--err-soft); border: 1px solid #f4b8b1; color: var(--err); border-radius: 6px; padding: 10px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 4px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; background: #fff; color: var(--muted); }

/* Login */
/* Fondo: la pantalla de venta ya desenfocada en el archivo (no hace falta filter: blur en el navegador).
   El velo oscuro hace que la tarjeta blanca no se pierda sobre una imagen casi toda blanca. */
/* min-height (no height): con alto fijo, una tarjeta mas alta que la pantalla (registro en celular) se
   sale por arriba al centrarla y esa parte no se puede desplazar */
.login-page {
  display: grid; place-items: center; padding: 16px; height: auto; min-height: 100%;
  background: linear-gradient(rgba(20, 38, 66, .45), rgba(20, 38, 66, .45)),
              url("../auth/fondo-login.jpg") center / cover no-repeat, var(--bg);
}
.login-card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 28px; display: grid; gap: 14px;
              box-shadow: 0 20px 50px rgba(10, 20, 40, .35); }
.login-negocio { margin: -6px 0 2px; font-size: 17px; font-weight: 600; color: var(--ink); }
.login-nota { margin: 0; font-size: 12.5px; }
.login-pie { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
.login-pie .link { font-size: 13px; color: var(--muted); }
.topbar .licencia-aviso { background: #fff3cd; color: #7a5600; text-decoration: none; font-weight: 600;
                          padding: 3px 10px; border-radius: 999px; font-size: 12.5px; }
.login-card h1 { margin: 0; color: var(--brand); }
.login-card p { margin: -8px 0 4px; font-size: 13px; }

/* Paginas de administracion */
.page { max-width: 1200px; margin: 0 auto; padding: 18px 16px 40px; }
.page h1 { font-size: 20px; margin: 0 0 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 16px; }
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; }
table.data th { background: #f6f8fb; font-weight: 600; font-size: 13px; color: var(--muted); position: sticky; top: 0; }
table.data tr.anulado td { color: var(--muted); text-decoration: line-through; }
table.data td.wrap { white-space: normal; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--line-soft); color: var(--muted); }
.tag.err { background: var(--err-soft); color: var(--err); }
.tag.warn { background: #fff4d6; color: var(--warn); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid { align-items: start; }   /* un campo mas alto no estira los demas de la fila */
/* minmax(0,1fr): sin esto la lista toma el ancho de su opcion mas larga y se sale de la columna */
.dep-campo { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; align-content: start; min-width: 0; }
.dep-campo label { grid-template-columns: minmax(0, 1fr); }
.dep-campo label select { width: 100%; min-width: 0; }
.dep-nuevo { display: flex; gap: 6px; }
.dep-nuevo input { flex: 1; min-width: 0; }
.dep-nuevo .btn { padding: 6px 10px; }
/* Campo de clave con ojito para mostrar/ocultar (data-ver-clave en utils.js) */
.pass-field { position: relative; display: block; }
.pass-field input { width: 100%; padding-right: 30px; }
.pass-toggle {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%); display: flex;
  border: 0; background: none; padding: 4px; margin: 0; cursor: pointer; color: var(--muted); border-radius: 4px;
}
.pass-toggle:hover { color: var(--ink); background: var(--line-soft); }
.pass-toggle .i-ojo-cerrado { display: none; }
.pass-toggle.on .i-ojo { display: none; }
.pass-toggle.on .i-ojo-cerrado { display: block; }
.checks { display: flex; flex-wrap: wrap; gap: 18px; margin: 14px 0; }
.checks label { display: flex; align-items: center; gap: 6px; color: var(--ink); }
.actions { display: flex; gap: 8px; margin-top: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ============ Documentos: informe a un lado, representacion al otro ============ */
.docs-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.docs { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 8px; padding: 8px; }
.docs-list { display: flex; flex-direction: column; gap: 6px; min-height: 0; min-width: 0; }
.docs-filtros { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; background: var(--brand-soft); border: 1px solid var(--line); padding: 8px 10px; }
.docs-filtros .grow { flex: 1; min-width: 160px; }
.docs-filtros input, .docs-filtros select { padding: 4px 6px; }
.docs-filtros .btn { padding: 5px 14px; }
.docs-grid-wrap { flex: 1; min-height: 0; overflow: auto; background: #fff; border: 1px solid #9aa7b6; }
table.docs-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.docs-grid th {
  position: sticky; top: 0; z-index: 1; background: #fff; text-align: left; font-weight: 400; font-size: 13px;
  padding: 5px 8px; border-bottom: 1px solid #9aa7b6; border-right: 1px solid var(--line); white-space: nowrap;
}
table.docs-grid th.num { text-align: right; }
table.docs-grid td { padding: 3px 8px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.docs-grid td.ell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
table.docs-grid tr.doc { cursor: default; }
table.docs-grid tr.doc:hover td { background: #f3f7fb; }
table.docs-grid tr.doc.on td { background: var(--brand); color: var(--brand-ink); }
table.docs-grid tr.doc.on .tag { background: rgba(255,255,255,.85); }
table.docs-grid tr.anulado td { color: var(--muted); text-decoration: line-through; }
table.docs-grid tr.anulado td:last-child { text-decoration: none; }
table.docs-grid tr.doc.on.anulado td { color: rgba(255,255,255,.75); }
table.docs-grid tfoot td { position: sticky; bottom: 0; background: #f6f8fb; font-weight: 600; border-top: 1px solid #9aa7b6; padding: 5px 8px; }
.docs-hint { font-size: 12px; }
.docs-preview { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.docs-actions { display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); padding: 6px 8px; }
.docs-actions .docs-num { font-weight: 600; margin-right: auto; }
.docs-actions .btn { padding: 5px 12px; }
.docs-preview iframe { flex: 1; min-height: 0; width: 100%; border: 1px solid var(--line); background: #e9ecef; }

/* Cartera */
.cartera-det { overflow-y: auto; }
.cart-nombre { font-size: 16px; font-weight: 600; }
.cart-saldo { font-size: 20px; font-weight: 700; color: var(--brand); }
.vencido { color: var(--err); font-weight: 600; }
table.docs-grid tr.doc.on .vencido { color: #ffd7d3; }
table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 3px 4px; border-bottom: 1px solid var(--line); }
table.mini td { padding: 4px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.mini th.num { text-align: right; }
table.mini tr.anulado td { color: var(--muted); text-decoration: line-through; }
.abono-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.abono-grid input, .abono-grid select { width: 100%; }
#f-abono .btn.primary { margin-top: 8px; width: 100%; }

/* Tarjetas laterales y totales (POS, cartera) */
.side-card { background: #fff; border: 1px solid var(--line); padding: 12px 14px; }
.side-card h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 26px; font-weight: 700; color: var(--brand); padding-top: 6px; border-top: 1px solid var(--line); margin-top: 4px; }
.totals .grand-l { align-self: end; padding-bottom: 4px; font-weight: 600; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; }
.side-card.total-band { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.side-card.total-band .t { font-size: 13px; opacity: .85; }
.side-card.total-band .v { font-size: 38px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; word-break: break-all; }

/* Lista desplegable de busqueda (planilla, informes) */
.field { position: relative; display: block; min-width: 0; }
.dropdown {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 30; background: #fff;
  border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  max-height: 340px; overflow-y: auto; display: none;
}
.dropdown.open { display: block; }
.dropdown .opt { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 6px 10px; cursor: pointer; border-bottom: 1px solid var(--line-soft); }
.dropdown .opt .n { font-weight: 500; }
.dropdown .opt .c { grid-column: 1; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.dropdown .opt .p { grid-row: 1 / span 2; grid-column: 2; align-self: center; text-align: right; font-variant-numeric: tabular-nums; }
.dropdown .opt .p small { display: block; color: var(--muted); font-size: 11px; }
.dropdown .opt.on { background: var(--sel); }
.dropdown .empty { padding: 10px; color: var(--muted); }
.dropdown .new { padding: 8px 10px; color: var(--brand); cursor: pointer; }

/* Informes */
.docs.solo-lista { grid-template-columns: minmax(0, 1fr); }
.informe-pick { min-width: 260px; flex: 1.2; }
.informe-pick input { width: 100%; font-weight: 600; }
.informe-pick input::placeholder { color: var(--ink); opacity: .75; }
.informe-titulo { font-size: 14px; padding: 0 2px; }
/* Documento en ventana modal (VP.abrirDocumento) */
.doc-modal { width: min(440px, 100%); height: min(88vh, 900px); display: flex; flex-direction: column; overflow: hidden; }
.doc-modal header { flex-shrink: 0; }
.doc-modal:focus { outline: none; }
.doc-modal-acciones { display: flex; gap: 6px; }
.doc-modal-frame { flex: 1; width: 100%; border: 0; background: #e9ecef; }

/* Modales */
.modal-back { position: fixed; inset: 0; background: rgba(15, 25, 40, .45); display: none; align-items: center; justify-content: center; z-index: 60; padding: 16px; }
.modal-back.open { display: flex; }
.modal { background: #fff; border-radius: 8px; width: min(480px, 100%); max-height: 100%; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal header h2 { margin: 0; font-size: 16px; }
.modal .body { padding: 16px 18px; display: grid; gap: 10px; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.pay-total { text-align: center; font-size: 34px; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.pay-row { display: grid; grid-template-columns: 120px 1fr 1fr; gap: 8px; align-items: center; }
.pay-row input { text-align: right; font-size: 16px; }
.pay-row input.ref { text-align: left; font-size: 13px; }
.pay-change { display: flex; justify-content: space-between; font-size: 20px; padding: 10px 12px; background: var(--ok-soft); border-radius: 6px; font-variant-numeric: tabular-nums; }
.pay-change.falta { background: var(--err-soft); color: var(--err); }
.form-err { color: var(--err); font-size: 13px; min-height: 18px; }

@media (max-width: 900px) {
  .docs-page { height: auto; overflow: visible; }
  .docs { grid-template-columns: minmax(0, 1fr); }
  .docs-grid-wrap { max-height: 55vh; }
  .docs-preview iframe { height: 70vh; flex: none; }
  table.docs-grid .h-sm { display: none; }
  .topbar { gap: 6px; padding: 0 8px; }
  .topbar nav a { padding: 6px 8px; }
  .topbar .who span { display: none; }
}

/* Estado de un pago de licencia (pagina de licencia y Plataforma) */
.pago-aprobado { color: var(--ok); font-weight: 600; }
.pago-pendiente { color: var(--warn); font-weight: 600; }
.pago-rechazado, .pago-anulado, .pago-error { color: var(--err); font-weight: 600; }

/* Soporte desde Plataforma: siempre visible que se esta dentro del negocio de un cliente */
.soporte-barra { background: #fff3cd; color: #6b4e00; border-bottom: 1px solid #f0d58a; padding: 7px 14px; font-size: 13.5px; text-align: center; }
.soporte-barra a { color: #6b4e00; font-weight: 700; margin-left: 10px; }
