/* Cupones Digitales · H.K. TOUR — colores tomados del logo */
:root {
  --navy: #0b2265;
  --navy-2: #13348f;
  --blue: #1f6fd1;
  --sky: #5fb0f0;
  --ice: #eaf3fd;
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #16213a;
  --muted: #64708a;
  --line: #dde4ef;
  --ok: #1a8f5a;
  --ok-bg: #e5f6ee;
  --warn: #b7791f;
  --warn-bg: #fdf3e1;
  --info: #1f6fd1;
  --info-bg: #e7f0fc;
  --err: #c0392b;
  --err-bg: #fdecea;
  --wa: #1fa855;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(11, 34, 101, .06), 0 6px 20px rgba(11, 34, 101, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
body.bare { background: linear-gradient(160deg, #eaf3fd 0%, #f7fbff 60%, #fff 100%); min-height: 100vh; }
a { color: var(--blue); }
h1 { font-size: 1.55rem; margin: 0 0 .15rem; color: var(--navy); letter-spacing: -.01em; }
h2, h3, h4 { color: var(--navy); }
code { background: var(--ice); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.muted { color: var(--muted); }
small.muted, .muted small { font-size: .82em; }
[hidden] { display: none !important; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem;
  background: var(--navy); color: #fff; padding: .55rem 1.25rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}
.brand { display: flex; align-items: center; gap: .65rem; color: #fff; text-decoration: none; font-weight: 600; }
.brand img { height: 38px; width: auto; background: #fff; border-radius: 8px; padding: 3px 6px; }
.nav { display: flex; align-items: center; gap: .25rem; margin-left: auto; flex-wrap: wrap; }
.nav a { color: #cfe0ff; text-decoration: none; padding: .45rem .7rem; border-radius: 8px; font-size: .93rem; }
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a.active { background: rgba(95, 176, 240, .22); color: #fff; }
.nav-user { display: flex; flex-direction: column; line-height: 1.1; font-size: .85rem; padding: 0 .6rem; border-left: 1px solid rgba(255, 255, 255, .2); margin-left: .4rem; }
.nav-user small { color: var(--sky); font-size: .72rem; }
.nav-logout button { background: transparent; border: 1px solid rgba(255, 255, 255, .35); color: #fff; border-radius: 8px; padding: .35rem .7rem; cursor: pointer; font: inherit; font-size: .85rem; }
.navtoggle { display: none; }
.navbtn { display: none; margin-left: auto; font-size: 1.5rem; cursor: pointer; padding: 0 .3rem; }

/* ---------- Layout ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.card-title { font-size: 1.05rem; margin: 0 0 .9rem; display: flex; align-items: center; gap: .55rem; }
.card-title span { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: #fff; font-size: .8rem; }
.narrow { max-width: 460px; }
.sec-title { margin: 1.6rem 0 .6rem; font-size: 1.05rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar-center { justify-content: center; margin-top: 1rem; }

/* ---------- Formularios ---------- */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .84rem; font-weight: 600; color: #34405c; margin-bottom: .85rem; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--text); width: 100%;
  border: 1px solid #cbd5e4; border-radius: 9px; padding: .55rem .7rem; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31, 111, 209, .15); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--navy); }
textarea { resize: vertical; }
.field-error { color: var(--err); font-weight: 500; font-size: .8rem; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 0 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; align-items: start; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.totales { display: flex; gap: 1rem; background: var(--ice); border-radius: 10px; padding: .8rem 1rem; }
.totales div { flex: 1; display: flex; flex-direction: column; }
.totales span { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.totales strong { font-size: 1.35rem; color: var(--navy); }
.totales strong.neg { color: var(--err); }

.filtros { display: flex; flex-wrap: wrap; gap: 0 .8rem; align-items: flex-end; padding-bottom: .3rem; }
.filtros label { flex: 1 1 140px; }
.filtros label.grow { flex: 2 1 240px; }
.filtros-btns { display: flex; gap: .4rem; margin-bottom: .85rem; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; font-size: .9rem; line-height: 1; white-space: nowrap;
  padding: .62rem 1rem; border-radius: 9px; border: 1px solid #cbd5e4;
  background: #fff; color: var(--navy); text-decoration: none; cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--ice); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--blue); }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-wa:hover { background: #18914a; }
.btn-wa-outline { color: var(--wa); border-color: var(--wa); }
.btn-wa-outline:hover { background: #e7f7ee; }
.btn-sm { padding: .42rem .7rem; font-size: .82rem; }
.btn-lg { padding: .85rem 1.6rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* ---------- Alertas / estatus ---------- */
.alert { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-ok { background: var(--ok-bg); color: #13603d; border-color: #bfe7d3; }
.alert-error { background: var(--err-bg); color: #8e2a20; border-color: #f5c6c0; }
.st-pendiente { --c: var(--warn); --cb: var(--warn-bg); }
.st-confirmado { --c: var(--info); --cb: var(--info-bg); }
.st-cobrado { --c: var(--ok); --cb: var(--ok-bg); }
.badge { display: inline-block; padding: .18rem .6rem; border-radius: 99px; font-size: .78rem; font-weight: 600; color: var(--c); background: var(--cb); }
.status-select { width: auto; padding: .3rem .5rem; font-size: .82rem; font-weight: 600; color: var(--c); background: var(--cb); border-color: transparent; border-radius: 99px; }
.chip { font: inherit; font-weight: 600; font-size: .85rem; padding: .4rem .9rem; border-radius: 99px; cursor: pointer; border: 1px solid var(--c); color: var(--c); background: #fff; }
.chip.is-on { background: var(--c); color: #fff; }
.admin-panel { display: flex; flex-direction: column; gap: .6rem; }
.estatus-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.historial summary { cursor: pointer; color: var(--blue); font-size: .88rem; }
.historial ul { margin: .5rem 0 0; padding-left: 1.1rem; font-size: .86rem; }
form.inline { margin: 0; }

/* ---------- Tablas ---------- */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8fafd; padding: .7rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: .65rem .8rem; border-bottom: 1px solid #edf1f7; vertical-align: middle; }
.table tbody tr:hover { background: #fafcff; }
.table .num { text-align: right; white-space: nowrap; }
.table .empty, .empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.table-compact td, .table-compact th { padding: .5rem .65rem; }
.table-edit input, .table-edit select { padding: .4rem .5rem; font-size: .88rem; min-width: 90px; }
.table-edit tr.is-off { opacity: .55; }
.table-edit .row-new { background: #f7fbff; }
.folio-link { font-weight: 700; color: var(--navy); text-decoration: none; font-variant-numeric: tabular-nums; }
.folio-link:hover { text-decoration: underline; }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; }

/* ---------- Reportes ---------- */
.reporte-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.reporte-head img { height: 56px; width: auto; }
.reporte-head h2 { margin: 0; }
.reporte-head p { margin: .1rem 0; font-size: .86rem; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-bottom: .5rem; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; box-shadow: var(--shadow); border-top: 3px solid var(--navy); }
.kpi span { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kpi strong { font-size: 1.3rem; color: var(--navy); font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: .8rem; }
.kpi-ok { border-top-color: var(--ok); }
.kpi-warn { border-top-color: var(--warn); }

/* ---------- Login / verificación ---------- */
.login-wrap { min-height: 80vh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 380px; padding: 2rem; text-align: center; }
.login-card form, .login-card label { text-align: left; }
.login-logo { max-width: 170px; max-height: 110px; width: auto; height: auto; margin: 0 auto .6rem; display: block; }
.login-card h1 { margin-bottom: .2rem; }
.verify { max-width: 820px; margin: 0 auto; }
.verify-msg { text-align: center; padding: 2.5rem 1.5rem; }
.verify-ok { background: var(--ok-bg); color: #13603d; border: 1px solid #bfe7d3; border-radius: 10px; padding: .7rem 1rem; text-align: center; font-weight: 600; margin-bottom: 1rem; }

/* ---------- Cupón ---------- */
.cupon {
  background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 10px 40px rgba(11, 34, 101, .12);
  border: 1px solid var(--line); max-width: 820px; margin: 0 auto 1rem; position: relative;
}
.cupon-head {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 1.2rem 1.5rem; border-bottom: 4px solid var(--navy);
  background: linear-gradient(135deg, #fff 55%, var(--ice) 100%);
}
.cupon-logo { flex: 0 1 220px; display: flex; align-items: center; }
.cupon-logo img { max-width: 100%; max-height: 90px; width: auto; height: auto; object-fit: contain; }
.cupon-title { text-align: right; display: flex; flex-direction: column; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; font-weight: 700; color: var(--blue); }
.cupon-folio { font-size: 2rem; font-weight: 800; color: var(--navy); letter-spacing: .02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.cupon-title .muted { font-size: .8rem; }
.cupon-band { display: grid; grid-template-columns: 2fr 1fr 1fr; background: var(--navy); color: #fff; }
.cupon-band div { padding: .7rem 1.5rem; display: flex; flex-direction: column; border-right: 1px solid rgba(255, 255, 255, .15); }
.cupon-band div:last-child { border-right: 0; }
.cupon-band span { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--sky); }
.cupon-band strong { font-size: 1.05rem; }
.cupon-body { display: flex; gap: 1.2rem; padding: 1.2rem 1.5rem; }
.cupon-grid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.4rem; }
.cupon-grid h4 { margin: 0 0 .4rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--blue); border-bottom: 1px solid var(--line); padding-bottom: .25rem; }
.cupon-grid dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .2rem .7rem; font-size: .9rem; }
.cupon-grid dt { color: var(--muted); }
.cupon-grid dd { margin: 0; font-weight: 600; }
.cupon-pagos { grid-column: 1 / -1; }
.cupon-pagos table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.cupon-pagos td { padding: .3rem 0; border-bottom: 1px dashed var(--line); }
.cupon-pagos td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.cupon-pagos .t-total td { font-weight: 700; border-bottom-style: solid; }
.cupon-pagos .t-saldo td { font-weight: 800; color: var(--navy); font-size: 1.05rem; border-bottom: 0; }
.cupon-qr { flex: 0 0 160px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: .4rem; padding: .7rem; border: 1px dashed #b9c8de; border-radius: 12px; height: fit-content; }
.cupon-qr .qr img, .cupon-qr .qr canvas { display: block; width: 132px; height: 132px; }
.cupon-qr small { color: var(--muted); font-size: .72rem; text-align: center; }
.cupon-notas { margin: 0 1.5rem 1rem; padding: .7rem .9rem; background: var(--ice); border-radius: 10px; font-size: .88rem; }
.cupon-firmas { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; padding: .6rem 1.5rem 1rem; }
.cupon-firmas div { display: flex; flex-direction: column; align-items: center; }
.cupon-firmas .linea { width: 100%; border-bottom: 1px solid #94a3bb; text-align: center; padding: 1.2rem 0 .2rem; font-weight: 600; font-size: .9rem; }
.cupon-firmas small { color: var(--muted); font-size: .75rem; margin-top: .2rem; }
.cupon-foot { background: #f6f9fd; border-top: 1px solid var(--line); padding: .8rem 1.5rem; font-size: .76rem; color: var(--muted); }
.cupon-foot p { margin: .15rem 0; }
.cupon-contacto strong { color: var(--navy); }
.wa-texto summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.wa-texto textarea { margin: .7rem 0; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.wa-texto { max-width: 820px; margin: 0 auto; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .form-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .navbtn { display: block; }
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch; background: var(--navy); padding: .5rem 1rem 1rem; }
  .navtoggle:checked ~ .nav { display: flex; }
  .nav-user { border: 0; margin: .5rem 0; padding: .4rem .7rem; }
  .nav-logout button { width: 100%; }
  .brand span { display: none; }
}
@media (max-width: 680px) {
  .container { padding: 1rem .9rem 2.5rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .toolbar .actions .btn { flex: 1 1 45%; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--line); padding: .5rem 0; }
  .table td { border: 0; padding: .3rem .9rem; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  .table td::before { content: attr(data-l); font-weight: 600; color: var(--muted); font-size: .78rem; text-align: left; }
  .table td.empty::before { content: none; }
  .table .num { text-align: right; }
  .cupon-head { flex-direction: column; align-items: flex-start; }
  .cupon-logo { flex: none; max-width: 200px; }
  .cupon-title { text-align: left; }
  .cupon-band { grid-template-columns: 1fr 1fr; }
  .cupon-band div:first-child { grid-column: 1 / -1; border-right: 0; border-bottom: 1px solid rgba(255, 255, 255, .15); }
  .cupon-body { flex-direction: column-reverse; }
  .cupon-qr { align-self: center; }
  .cupon-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr; }
}

/* ---------- PDF / impresión ---------- */
body.pdf-mode .cupon { box-shadow: none; }
@media print {
  @page { size: letter; margin: 10mm; }
  body, body.bare { background: #fff; }
  .no-print, .topbar, .alert { display: none !important; }
  .container { padding: 0; max-width: none; }
  .cupon { box-shadow: none; border: 1px solid #c9d3e3; break-inside: avoid; }
  .card { box-shadow: none; }
  .table-wrap { overflow: visible; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Indicaciones, políticas y pago opcional ---------- */
.cupon-notas h4, .cupon-foot h4 { margin: 0 0 .3rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--blue); }
.cupon-notas p { margin: 0; line-height: 1.55; }
.cupon-politicas { margin: 0 0 .5rem; padding-left: 1.1rem; }
.cupon-politicas li { margin: .12rem 0; }
.pago-opcional summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.pago-opcional[open] summary { margin-bottom: .9rem; }
.form-grid > .pago-opcional { grid-column: 1 / -1; }
.table-edit td.td-wide { min-width: 320px; }
.table-edit textarea { font-size: .86rem; padding: .4rem .5rem; }

/* ---------- Cancelación, eliminar e idioma ---------- */
.st-cancelado { --c: #b42318; --cb: #fdecea; }
.btn-danger { background: #b42318; border-color: #b42318; color: #fff; }
.btn-danger:hover { background: #912018; }
.btn-danger-ghost { color: #b42318; border-color: #f1c4bf; background: #fff; }
.btn-danger-ghost:hover { background: #fdecea; }
.row-actions { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.table tr.is-cancelled td { color: var(--muted); }
.table tr.is-cancelled .folio-link { text-decoration: line-through; color: var(--muted); }
.cancelar summary { cursor: pointer; color: #b42318; font-weight: 600; font-size: .9rem; }
.cancelar-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; margin-top: .6rem; }
.cancelar-form label { flex: 1 1 260px; margin-bottom: 0; }
.cupon.is-cancelled .cupon-head, .cupon.is-cancelled .cupon-body, .cupon.is-cancelled .cupon-band { opacity: .55; }
.cupon-sello {
  position: absolute; z-index: 5; top: 38%; left: 50%; transform: translate(-50%, -50%) rotate(-14deg);
  border: 6px solid #b42318; color: #b42318; border-radius: 12px; padding: .3rem 1.4rem;
  font-size: 3rem; font-weight: 900; letter-spacing: .12em; background: rgba(255, 255, 255, .85); pointer-events: none;
}
.verify-bad { background: #fdecea; color: #8e2a20; border: 1px solid #f5c6c0; border-radius: 10px; padding: .8rem 1rem; text-align: center; font-weight: 700; margin-bottom: 1rem; }
.lang-switch { display: flex; justify-content: flex-end; gap: .3rem; margin: -.8rem -.6rem .4rem 0; }
.lang-switch a { font-size: .8rem; padding: .2rem .55rem; border-radius: 99px; text-decoration: none; color: var(--muted); }
.lang-switch a.on { background: var(--navy); color: #fff; }
.lang-choice { display: flex; gap: .5rem; }
.lang-choice .chip { --c: var(--navy); }
@media (max-width: 680px) { .cupon-sello { font-size: 2rem; } }

/* ---------- Precios por tour y reporte de ventas ---------- */
.precios-grid { display: grid; grid-template-columns: auto 92px 92px; gap: .3rem .4rem; align-items: center; font-size: .78rem; }
.precios-grid span { color: var(--muted); font-weight: 600; white-space: nowrap; }
.precios-grid small { color: var(--muted); text-align: center; }
.table-edit .precios-grid input { min-width: 0; }
.precios-pie { display: flex; gap: .5rem; align-items: center; margin-top: .35rem; }
.precios-pie select { width: auto; }
.rangos { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.chip-range { font-size: .82rem; font-weight: 600; padding: .35rem .8rem; border-radius: 99px; border: 1px solid #cbd5e4; background: #fff; color: var(--navy); text-decoration: none; }
.chip-range:hover { background: var(--ice); }
.chip-range.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.table-ventas .th-grupo th { background: #eef3fa; text-align: center; padding: .3rem; }
.table-ventas td, .table-ventas th { white-space: nowrap; }
.table tr.row-cancelado td { background: #f1ecf7; color: #5b4a75; }
.totales { flex-wrap: wrap; }
.totales div { min-width: 140px; }
@media print { .table-ventas { font-size: .72rem; } }
