/* Estilo de Gestión de Valor (gdv.gestiondevalor.com): azul noche de marca, verde azulado como color
   principal, Inter para el texto y Poppins para títulos. Las fuentes vienen de ese mismo sitio. */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/fuentes/inter-latin.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 600; font-display: swap; src: url("/fuentes/poppins-600-latin.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 700; font-display: swap; src: url("/fuentes/poppins-700-latin.woff2") format("woff2"); }

:root {
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Poppins", "Inter", system-ui, sans-serif;

  /* marca (siempre oscura: encabezado, ingreso, avisos). Valores medidos en gdv.gestiondevalor.com */
  --marca: #07071c;
  --marca-2: #0d0e26;
  --marca-3: #131531;
  --marca-line: #1e2040;
  --marca-ink: #eef1f7;
  --marca-muted: #b4bcd0;
  --teal-vivo: #41bdaf;

  /* tema claro */
  --bg: hsl(210 40% 98%);
  --surface: #ffffff;
  --surface-2: hsl(210 40% 96.1%);
  --ink: hsl(222.2 47.4% 11.2%);
  --muted: hsl(215.3 19.3% 34.5%);
  --line: hsl(214.3 31.8% 91.4%);
  --input-line: hsl(216.7 17% 58.4%);
  --accent: hsl(173.4 51.9% 31%);
  --accent-hover: hsl(173.8 52.3% 25.5%);
  --accent-ink: #ffffff;
  --accent-soft: hsl(173 50% 31% / .1);
  --btn-bg: #ffffff;
  --btn-line: hsl(216.7 17% 58.4% / .55);
  --neg: hsl(0 73.7% 41.8%);
  --ok: hsl(142.1 76.2% 36.3%);
  --ok-bg: hsl(141 79% 93%);
  --ok-ink: hsl(142.8 64.2% 24.1%);
  --warn: hsl(22.7 82.5% 31.4%);
  --warn-bg: hsl(48 96% 89%);
  --bad: hsl(0 73.7% 41.8%);
  --bad-bg: hsl(0 93% 94%);
  --radius: 12px;
  --radius-sm: 8px;
  --toque: 44px;
  --shadow: 0 1px 2px hsl(222 47% 11% / .06), 0 4px 16px hsl(222 47% 11% / .05);
  color-scheme: light dark;
}

/* Tema oscuro: sigue al dispositivo, salvo que la persona elija uno con el botón del encabezado
   (data-tema en <html>). Los dos bloques tienen los mismos valores. */
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --bg: var(--marca); --surface: var(--marca-2); --surface-2: var(--marca-3);
    --ink: var(--marca-ink); --muted: var(--marca-muted); --line: #252949; --input-line: #6b7396;
    --accent: var(--teal-vivo); --accent-hover: #5ccfc2; --accent-ink: var(--marca); --accent-soft: rgba(65, 189, 175, .16);
    --btn-bg: var(--marca-3); --btn-line: rgba(107, 115, 150, .55); --neg: #ff9b9b;
    --ok: #4ade80; --ok-bg: #0f2e22; --ok-ink: #6ee7a0;
    --warn: #fbbf24; --warn-bg: #2e2410; --bad: #ff9b9b; --bad-bg: #3a1618;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-tema="oscuro"] {
  --bg: var(--marca); --surface: var(--marca-2); --surface-2: var(--marca-3);
  --ink: var(--marca-ink); --muted: var(--marca-muted); --line: #252949; --input-line: #6b7396;
  --accent: var(--teal-vivo); --accent-hover: #5ccfc2; --accent-ink: var(--marca); --accent-soft: rgba(65, 189, 175, .16);
  --btn-bg: var(--marca-3); --btn-line: rgba(107, 115, 150, .55); --neg: #ff9b9b;
  --ok: #4ade80; --ok-bg: #0f2e22; --ok-ink: #6ee7a0;
  --warn: #fbbf24; --warn-bg: #2e2410; --bad: #ff9b9b; --bad-bg: #3a1618;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
:root[data-tema="claro"] { color-scheme: light; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; }
h2 { font-size: 1rem; letter-spacing: -.01em; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- marca y encabezado ---------- */

.brand { display: inline-flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 700; letter-spacing: -.01em; font-size: 1.15rem; }
.brand svg { flex: none; }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right));
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--marca); color: var(--marca-ink);
  border-bottom: 1px solid var(--marca-line);
  box-shadow: 0 1px 0 rgba(65, 189, 175, .45);
}
.top .biz { flex: 1; min-width: 0; color: var(--marca-muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .ghost { color: var(--marca-ink); border-color: var(--marca-line); }
.tema-btn { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--marca-line); background: transparent; color: var(--marca-ink); cursor: pointer; }
.tema-btn:hover { background: var(--marca-3); }
.tema-btn svg { width: 18px; height: 18px; }

.conn { display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--marca-2); color: var(--marca-ink); border: 1px solid var(--marca-line); white-space: nowrap; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: hsl(229 17% 50%); }
.conn.ok::before { background: var(--teal-vivo); box-shadow: 0 0 0 0 hsl(173 49% 50% / .6); animation: pulse 2s infinite; }
.conn.warn::before { background: hsl(43 96% 64%); }
.conn.bad { background: hsl(0 55% 14%); color: hsl(0 91% 85%); border-color: hsl(0 50% 25%); }
.conn.bad::before { background: hsl(0 91% 71%); }

@keyframes pulse { 70% { box-shadow: 0 0 0 7px hsl(173 49% 50% / 0); } 100% { box-shadow: 0 0 0 0 hsl(173 49% 50% / 0); } }

.tabs { display: flex; gap: 4px; padding: 6px 12px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; position: sticky; top: 53px; z-index: 15; }
.tabs a { flex: none; padding: 8px 14px; border-radius: var(--radius-sm); text-decoration: none; font-weight: 600; font-size: .92rem; color: var(--muted); }
.tabs a:hover { color: var(--ink); background: var(--surface-2); }
.tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); box-shadow: inset 0 -3px 0 var(--accent); }

main#view { padding: 16px; max-width: 1180px; margin: 0 auto; padding-bottom: max(32px, env(safe-area-inset-bottom)); }

/* ---------- piezas comunes ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card > h2 { margin-bottom: 10px; }
.card > p { color: var(--muted); }
.stack { display: grid; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--toque); padding: 0 20px; border-radius: var(--radius-sm);
  border: 1px solid var(--btn-line); background: var(--btn-bg); color: var(--ink);
  font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { border-color: var(--input-line); }
.btn.primary, .btn.go { font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.go { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; min-height: 48px; }
.btn[disabled] { opacity: .55; cursor: default; }
@media (prefers-color-scheme: dark) { :root:not([data-tema="claro"]) .btn.go { color: var(--marca); } }
:root[data-tema="oscuro"] .btn.go { color: var(--marca); }

.ghost { background: none; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 7px 12px; cursor: pointer; font-weight: 600; }
.ghost.small { font-size: .85rem; }
.icon-btn { flex: none; width: var(--toque); height: var(--toque); border-radius: 50%; border: 0; background: var(--surface-2); color: var(--muted); font-size: 1.1rem; cursor: pointer; }

label.field { display: grid; gap: 6px; font-weight: 500; font-size: .82rem; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], select {
  width: 100%; min-height: var(--toque); padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--input-line); background: var(--surface); color: var(--ink); font-size: 1rem;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px hsl(173 49% 50% / .22); }
input::placeholder { color: var(--muted); opacity: .75; }
.help { color: var(--muted); font-size: .82rem; font-weight: 400; }
.error { color: var(--bad); font-weight: 600; font-size: .9rem; min-height: 1.3em; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.seg button { min-height: 38px; border: 0; border-radius: 6px; background: none; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px hsl(222 47% 11% / .18); }

.banner { padding: 12px 14px; border-radius: var(--radius-sm); font-size: .92rem; display: grid; gap: 2px; margin-bottom: 12px; }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.info { background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.banner strong { color: inherit; }

/* ---------- ingreso (como el acceso de GDV: siempre oscuro, tarjeta con línea de color arriba) ---------- */

.login {
  --bg: var(--marca); --surface: var(--marca-2); --surface-2: var(--marca-3);
  --ink: var(--marca-ink); --muted: var(--marca-muted); --line: #252949;
  --input-line: #6b7396; --accent: var(--teal-vivo); --accent-hover: #5ccfc2;
  --accent-ink: var(--marca); --bad: #ff9b9b; --btn-bg: var(--marca-3); --btn-line: rgba(107, 115, 150, .55);
  color-scheme: dark;
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: var(--bg); color: var(--ink);
}
.login-box {
  position: relative; overflow: hidden;
  width: 100%; max-width: 380px; display: grid; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 24px 24px; box-shadow: 0 20px 50px hsl(240 60% 3% / .55);
}
.login-box::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg, hsl(173 49% 50% / .2), var(--teal-vivo), hsl(173 49% 50% / .2)); }
.login .brand { font-size: 1.6rem; justify-self: center; }
.login .tagline { color: var(--muted); margin-top: -8px; text-align: center; font-size: .92rem; }
.login form { display: grid; gap: 14px; }
.login .seg { background: var(--marca); }
.login .seg button[aria-pressed="true"] { background: var(--marca-3); box-shadow: inset 0 -2px 0 var(--teal-vivo); }
.activate-title { font-size: 1.15rem; text-align: center; }
input.pin { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- pantalla en vivo ---------- */

.caja { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .caja { grid-template-columns: minmax(360px, 430px) 1fr; align-items: start; }
  .col-main { position: sticky; top: 124px; }
  .caja.solo .col-main { top: 72px; }
}

.expect .lbl { display: block; font-family: var(--display); font-weight: 600; font-size: 1rem; margin-bottom: 10px; }
.amt-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 16px; border-radius: var(--radius); border: 1px solid var(--input-line); background: var(--surface); }
.amt-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px hsl(173 49% 50% / .22); }
.amt-row .cur { font-size: 1.9rem; font-weight: 600; color: var(--muted); }
.amt-row input { flex: 1; min-width: 0; border: 0; background: none; padding: 0; min-height: 60px; font-size: 2.3rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; outline: none; box-shadow: none; }

.result { margin-top: 14px; border-radius: var(--radius); }
.result.idle .hint { color: var(--muted); font-size: .92rem; }
.result.wait, .result.ok, .result.bad { padding: 16px; display: grid; gap: 12px; }
.result.wait { background: var(--surface-2); border: 1px dashed var(--input-line); }
.result.ok { background: var(--ok-bg); color: var(--ok-ink); animation: pop .35s ease-out; }
.result.bad { background: var(--bad-bg); color: var(--bad); }
@keyframes pop { from { transform: scale(.97); opacity: .4; } }

.res-head { display: flex; gap: 12px; align-items: flex-start; }
.res-head strong { display: block; font-family: var(--display); font-weight: 600; font-size: 1.35rem; line-height: 1.25; }
.res-sub { display: block; font-size: .9rem; margin-top: 3px; opacity: .9; }
.res-icon { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-size: 1.5rem; font-weight: 800; }
.res-old { font-weight: 600; color: var(--warn); background: var(--warn-bg); padding: 8px 10px; border-radius: var(--radius-sm); font-size: .9rem; }
.note { font-size: .9rem; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn); }
.confirm { display: grid; gap: 8px; }
.confirm input { background: var(--surface); }
.pick { display: grid; gap: 8px; list-style: none; padding: 0; margin: 0; }
.pick li { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface); color: var(--ink); padding: 8px 8px 8px 12px; border-radius: var(--radius-sm); font-size: .92rem; }

.spinner { flex: none; width: 34px; height: 34px; margin: 5px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 4px 2px 10px; }
#dir-toggle { margin-bottom: 12px; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row {
  width: 100%; text-align: left; cursor: pointer;
  display: grid; gap: 4px; padding: 13px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); border-left: 4px solid var(--ok);
  box-shadow: var(--shadow);
}
.row:hover { border-color: var(--input-line); border-left-color: var(--ok); }
.row.claimed { border-left-color: var(--line); background: var(--surface-2); box-shadow: none; }
.row.claimed:hover { border-left-color: var(--line); }
.row.off { border-left-color: var(--warn); }
.row.out { border-left-color: var(--input-line); }
.r-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.r-amt { font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.row.out .r-amt { color: var(--neg); }
.row.claimed .r-amt, .row.off .r-amt { color: var(--muted); }
.row.off .r-amt { text-decoration: line-through; }
.r-time { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.r-sub { font-size: .86rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { justify-self: start; display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.tag.new { background: var(--ok-bg); color: var(--ok-ink); }
.tag.new::before, .pill.ok::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.done { background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }

.empty { text-align: center; color: var(--muted); padding: 36px 16px; border: 1px dashed var(--input-line); border-radius: var(--radius); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; font-family: var(--display); font-weight: 600; }

/* ---------- detalle ---------- */

.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: hsl(240 60% 4% / .6); }
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow: auto;
  background: var(--surface); border-radius: 16px 16px 0 0; padding: 20px 18px max(20px, env(safe-area-inset-bottom));
  display: grid; gap: 14px; animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: 460px; border-radius: var(--radius); border: 1px solid var(--line); animation: none; }
}
.sheet-amt { font-size: 2.1rem; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kv { margin: 0; display: grid; gap: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv dt { color: var(--muted); font-size: .88rem; flex: none; }
.kv dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }
pre.raw { margin: 0; max-height: 260px; overflow: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; font-size: .75rem; }

/* ---------- administración ---------- */

.page { display: grid; gap: 16px; max-width: 860px; margin: 0 auto; }
.page .card + .card { margin-top: 0; }
.filters { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; align-items: end; }
.filters .wide { grid-column: 1 / -1; }
@media (min-width: 700px) { .filters { grid-template-columns: 1fr 1fr 1fr auto auto; } .filters .wide { grid-column: auto; } }

.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 2px; box-shadow: var(--shadow); }
.stat span { color: var(--muted); font-size: .75rem; font-weight: 400; }
.stat strong { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); }
.stat.warn strong { color: var(--warn); }
.stat.ok strong { color: var(--ok); }

.emps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.emp { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px; }
.emp.off { opacity: .6; }
.emp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.emp-pin { display: flex; gap: 8px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; flex: none; width: 46px; height: 26px; border-radius: 999px; background: var(--input-line); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(20px); }

.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); }
.pill.ok { background: var(--ok-bg); color: var(--ok-ink); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.off { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.client .emp-head { flex-wrap: wrap; }
.client .btn { min-height: 40px; padding: 0 14px; font-size: .9rem; }
input.search { max-width: 220px; min-height: 38px; }
details > summary { cursor: pointer; font-weight: 600; padding: 8px 0; color: var(--muted); }

/* ---------- avisos ---------- */

#toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--marca); color: var(--marca-ink); border: 1px solid var(--marca-line); padding: 13px 16px; border-radius: var(--radius-sm); font-weight: 600; box-shadow: 0 8px 30px hsl(240 60% 3% / .35); animation: up .2s ease-out; text-align: center; }
.toast.bad { background: hsl(0 60% 30%); border-color: hsl(0 60% 38%); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .spinner { border-top-color: var(--line); }
}
