/* ==========================================================================
   EloPago — plataforma operativa
   Barra lateral navy, contenido sobre gris azulado frío; las tablas
   financieras son el elemento principal: cifras tabulares alineadas a la
   derecha, estados como píldoras semánticas, nada decorativo.
   ========================================================================== */
:root {
  color-scheme: light;
  --navy: #071c39;
  --navy-2: #0e2a52;
  --blue: #0769cb;
  --blue-700: #0554a5;
  --teal: #12b8ae;
  --teal-ink: #0b7d76;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --line: #dfe6ef;
  --line-strong: #c4cfdd;
  --ink: #0b1b33;
  --ink-2: #26395a;
  --muted: #5a6b82;
  --ok: #0c7d55; --ok-bg: #e5f5ed;
  --warn: #965a00; --warn-bg: #fff3dc;
  --err: #b42f27; --err-bg: #fdebe9;
  --info: #0554a5; --info-bg: #e7f0fb;
  --neutral: #4a5a70; --neutral-bg: #eef2f7;
  --c1: #0769cb; --c2: #12b8ae; --c3: #071c39; --c4: #6aa5ef; --c5: #8edbd3; --c6: #a6b4c8;

  --font: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
  --radius-lg: 14px;
  --ring: 0 0 0 3px rgba(7, 105, 203, .28);
  --side-w: 248px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.015em; text-wrap: balance; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
a { color: var(--blue); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num, td.r, .money { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .86em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 15px; height: 15px; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 8px; }
.skip:focus { top: 12px; }

.env-bar { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 6px 16px calc(6px); padding-top: calc(6px + env(safe-area-inset-top, 0px)); background: #fff3dc; color: #6b4100; font-size: 12.5px; font-weight: 600; text-align: center; border-bottom: 1px solid #f1dcb1; }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; background: linear-gradient(90deg, var(--navy) var(--side-w), transparent var(--side-w)); }
.sidebar { background: var(--navy); color: #c6d3e6; padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.side-brand { padding: 2px 10px 0; }
.side-brand img { height: 30px; width: auto; }
.side-area { padding: 0 10px; font-size: 12px; font-weight: 700; color: var(--teal); display: grid; gap: 2px; }
.side-area span { color: #fff; font-size: 14px; font-weight: 700; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #c6d3e6; text-decoration: none; font-size: 14px; font-weight: 600; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar nav a[aria-current="page"] { background: rgba(18, 184, 174, .14); color: #fff; box-shadow: inset 3px 0 0 var(--teal); }
.sidebar nav a .ico { color: #8fa4c2; }
.sidebar nav a[aria-current="page"] .ico { color: var(--teal); }
.sidebar :focus-visible { outline-color: var(--teal); }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; height: 60px; padding: 0 28px; background: rgba(255, 255, 255, .94); border-bottom: 1px solid var(--line); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.topbar-title { font-weight: 700; color: var(--ink-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-weight: 600; font-size: 14px; text-decoration: none; padding: 6px 8px; border-radius: 8px; }
.user-link:hover { background: var(--bg); }
.menu-toggle { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); align-items: center; justify-content: center; cursor: pointer; }
.content { padding: 28px; display: grid; gap: 22px; align-content: start; max-width: 1240px; width: 100%; }
@media (max-width: 980px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(280px, 86vw); z-index: 60; transform: translateX(-100%); transition: transform .2s; box-shadow: 20px 0 40px rgba(7, 28, 57, .3); }
  .sidebar.is-open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px; }
  .user-link span { display: none; }
}

/* ---------- Pantallas sin barra lateral (login, checkout) ---------- */
.is-bare { background: var(--bg); }
.bare-main { max-width: 520px; margin: 0 auto; padding: 40px 16px 64px; display: grid; gap: 20px; }
.bare-main.wide { max-width: 760px; }
.bare-brand img { height: 34px; width: auto; }

/* ---------- Encabezados ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -.025em; }
.page-head p { color: var(--muted); margin-top: 4px; max-width: 70ch; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; display: inline-flex; gap: 4px; align-items: center; margin-bottom: 6px; }
.crumb:hover { color: var(--blue); }
.section-title { font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.section-title small { font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- Paneles ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; display: grid; gap: 14px; min-width: 0; align-content: start; }
.panel-flush { padding: 0; gap: 0; overflow: hidden; }
.panel-flush > .section-title { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-note { background: var(--neutral-bg); border-color: transparent; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1080px) { .grid-main, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* Indicadores calculados de la base (nunca inventados) */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.stat { background: var(--surface); padding: 16px 18px; display: grid; gap: 4px; }
.stat dt { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.stat dd { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 12px; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 16px; border-radius: 9px; font-weight: 700; font-size: 14px; text-decoration: none; border: 1px solid transparent; cursor: pointer; white-space: nowrap; background: none; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-700); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-2); }
.btn-danger { background: var(--surface); border-color: #e8b4af; color: var(--err); }
.btn-danger:hover { background: var(--err-bg); }
.btn-quiet { color: var(--ink-2); }
.btn-quiet:hover { background: var(--bg); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.inline-form { display: inline; }

/* ---------- Píldoras ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; line-height: 1.5; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-err { background: var(--err-bg); color: var(--err); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-neutral { background: var(--neutral-bg); color: var(--neutral); }
.tag { display: inline-flex; font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 5px; background: var(--warn-bg); color: var(--warn); white-space: nowrap; }
.tag-quiet { background: var(--neutral-bg); color: var(--neutral); }

/* ---------- Mensajes ---------- */
.flash { padding: 12px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; border: 1px solid; }
.flash-ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe3d0; }
.flash-error { background: var(--err-bg); color: var(--err); border-color: #f2c4bf; }
.flash-info { background: var(--info-bg); color: var(--info); border-color: #c5daf3; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 14px; background: var(--neutral-bg); color: var(--ink-2); }
.notice .ico { margin-top: 2px; }
.notice-warn { background: var(--warn-bg); color: #5f3a00; }
.notice-warn .ico { color: var(--warn); }
.notice-err { background: var(--err-bg); color: #7a1f19; }
.notice-ok { background: var(--ok-bg); color: #0a5a3e; }
.notice ul { padding-left: 18px; margin-top: 4px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafcfe; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.r, .table th.r { text-align: right; white-space: nowrap; }
.table tbody tr:hover { background: #fafcfe; }
.table .strong { font-weight: 700; }
.table a.row-link { color: var(--ink); font-weight: 700; text-decoration: none; }
.table a.row-link:hover { color: var(--blue); text-decoration: underline; }
.table tfoot td { font-weight: 800; border-top: 1px solid var(--line-strong); }
.table .sub { display: block; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty strong { color: var(--ink); font-size: 15px; }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.hint { font-size: 12.5px; color: var(--muted); }
.field-error { font-size: 12.5px; color: var(--err); font-weight: 600; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); font-size: 15px; }
textarea { min-height: 88px; resize: vertical; }
input[type="file"] { font-size: 14px; }
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a6b82' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; background-size: 17px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
[aria-invalid="true"] { border-color: var(--err) !important; }
.input-money { position: relative; }
.input-money > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-weight: 800; color: var(--muted); }
.input-money input { padding-left: 30px !important; font-variant-numeric: tabular-nums; font-weight: 700; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 3px; accent-color: var(--blue); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

/* ---------- Listas de definición ---------- */
.kv { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: 8px 18px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* ---------- Desglose de cálculo ---------- */
.calc { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.calc-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; align-items: center; }
.calc-row:last-child { border-bottom: 0; }
.calc-row .amt { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.calc-row.head { background: var(--navy); color: #fff; }
.calc-row.head .amt { font-size: 18px; font-weight: 800; }
.calc-row.fee { background: #fafcfe; }
.calc-row.total { background: var(--ok-bg); color: var(--ok); font-weight: 800; }
.calc-row.total.bad { background: var(--err-bg); color: var(--err); }
.calc-row .who { display: flex; gap: 8px; align-items: center; min-width: 0; }
.calc-row .who small { color: var(--muted); font-weight: 500; display: block; }
.sw { width: 10px; height: 10px; border-radius: 3px; flex: none; background: var(--c6); }
.sw.c1 { background: var(--c1); } .sw.c2 { background: var(--c2); } .sw.c3 { background: var(--c3); } .sw.c4 { background: var(--c4); } .sw.c5 { background: var(--c5); } .sw.fee { background: repeating-linear-gradient(135deg, var(--muted) 0 2px, transparent 2px 4px); }
.ribbon { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--line); }
.ribbon span { min-width: 0; }
.ribbon span + span { box-shadow: inset 2px 0 0 var(--surface); }
.ribbon .c1 { background: var(--c1); } .ribbon .c2 { background: var(--c2); } .ribbon .c3 { background: var(--c3); } .ribbon .c4 { background: var(--c4); } .ribbon .c5 { background: var(--c5); } .ribbon .fee { background: repeating-linear-gradient(135deg, var(--muted) 0 2px, #e8edf4 2px 4px); }

/* ---------- Ciclo de la cobranza ---------- */
.lifecycle { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; counter-reset: lc; }
.lc-step { position: relative; padding: 0 8px 0 0; display: grid; gap: 4px; }
.lc-step::before { content: ""; height: 4px; border-radius: 2px; background: var(--line); margin-bottom: 8px; }
.lc-step.done::before { background: var(--ok); }
.lc-step.warn::before { background: var(--warn); }
.lc-step.err::before { background: var(--err); }
.lc-step.now::before { background: var(--blue); }
.lc-step b { font-size: 13px; }
.lc-step span { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .lifecycle { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 14px; } }

/* ---------- Historial ---------- */
.timeline { list-style: none; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.timeline b { font-weight: 700; }
.timeline .meta { color: var(--muted); font-size: 12.5px; display: block; overflow-wrap: anywhere; }

/* ---------- Constructor de reglas ---------- */
.rule-rows { display: grid; gap: 8px; }
.rule-row { display: grid; grid-template-columns: minmax(0, 1.6fr) 120px 140px 40px; gap: 8px; align-items: center; }
.rule-head { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.icon-btn { width: 40px; height: 40px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--err-bg); color: var(--err); }
@media (max-width: 640px) { .rule-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; } .rule-row > :first-child { grid-column: 1 / -1; } .rule-head { display: none; } }

/* ---------- Checkout ---------- */
.checkout { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: 0 1px 2px rgba(7, 28, 57, .06), 0 18px 40px -20px rgba(7, 28, 57, .25); }
.checkout-head { background: var(--navy); color: #fff; padding: 22px 24px; display: grid; gap: 6px; }
.checkout-head .amount { font-size: 34px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.checkout-head p { color: #b7c6dc; font-size: 14px; }
.checkout-body { padding: 22px 24px; display: grid; gap: 18px; }
.methods { display: grid; gap: 8px; }
.method { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 10px; cursor: pointer; font-weight: 600; }
.method:has(input:checked) { border-color: var(--blue); box-shadow: var(--ring); }
.method input { accent-color: var(--blue); }
.method small { display: block; color: var(--muted); font-weight: 500; }

/* ---------- Diálogo de confirmación ---------- */
dialog { border: 0; border-radius: 16px; padding: 0; max-width: min(460px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(7, 28, 57, .35); }
dialog::backdrop { background: rgba(7, 28, 57, .45); }
.dlg { padding: 22px; display: grid; gap: 14px; }
.dlg h2 { font-size: 18px; font-weight: 800; }

/* ---------- Pestañas ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 10px 12px; font-weight: 700; font-size: 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--teal); }

/* ---------- Guía de la jornada ---------- */
.journey { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; counter-reset: j; list-style: none; }
.journey li { counter-increment: j; padding: 8px 10px; line-height: 1.35; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; display: grid; gap: 4px; }
.journey li::before { content: counter(j); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--neutral-bg); color: var(--ink-2); font-weight: 800; font-size: 12px; }
.journey li.done::before { content: "✓"; background: var(--ok-bg); color: var(--ok); }
.journey li a { font-weight: 700; text-decoration: none; }

.code-block { background: var(--navy); color: #d6e1ef; border-radius: 10px; padding: 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; overflow-x: auto; white-space: pre; }
.secret { font-family: var(--mono); background: var(--warn-bg); padding: 10px 12px; border-radius: 8px; overflow-wrap: anywhere; font-size: 13px; }
details.more summary { cursor: pointer; font-weight: 700; color: var(--blue); font-size: 14px; }
details.more[open] summary { margin-bottom: 10px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
.h-bare { font-size: 23px; font-weight: 800; letter-spacing: -.02em; }
.journey li { grid-template-columns: 22px minmax(0, 1fr); column-gap: 10px; row-gap: 0; align-items: center; }
.journey li::before { grid-row: span 2; }
.journey li > :not(a) { font-size: 12px; color: var(--ink-3, #5b6b80); }
