/* Sistema de Cobros — liquid glass (estilo iOS) + accesibilidad */
:root {
  --fscale: 1;
  --ink: #0b1220;
  --ink-2: rgba(11, 18, 32, 0.68);
  --ink-3: rgba(11, 18, 32, 0.5);
  --glass: rgba(255, 255, 255, 0.55);
  --glass-2: rgba(255, 255, 255, 0.78);
  --glass-hover: rgba(255, 255, 255, 0.72);
  --line: rgba(11, 18, 32, 0.1);
  --edge: rgba(255, 255, 255, 0.9);
  --shadow: 0 18px 40px -12px rgba(40, 60, 140, 0.28), 0 2px 8px rgba(40, 60, 140, 0.08);
  --accent: #0a6cf0;
  --accent-2: #0553c9;
  --accent-text: #0a56c4;
  --ok: #0b7a3b;
  --ok-bg: rgba(20, 160, 80, 0.16);
  --warn: #8a4b00;
  --warn-bg: rgba(255, 159, 10, 0.2);
  --bad: #b3261e;
  --bad-bg: rgba(255, 59, 48, 0.16);
  --info: #0a56c4;
  --info-bg: rgba(10, 108, 240, 0.14);
  --focus: #5b2df0;
  --bg-a: #cfe0ff;
  --bg-b: #f3e6ff;
  --blob1: #6aa8ff;
  --blob2: #c58bff;
  --blob3: #6fe3c2;
  --blur: 26px;
  --r-lg: 26px;
  --r-md: 18px;
  --r-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", system-ui, Roboto, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --ink: #f1f4ff;
  --ink-2: rgba(241, 244, 255, 0.75);
  --ink-3: rgba(241, 244, 255, 0.55);
  --glass: rgba(34, 38, 62, 0.5);
  --glass-2: rgba(40, 45, 72, 0.72);
  --glass-hover: rgba(52, 58, 92, 0.65);
  --line: rgba(255, 255, 255, 0.12);
  --edge: rgba(255, 255, 255, 0.35);
  --shadow: 0 20px 44px -14px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.3);
  --accent: #3b8bff;
  --accent-2: #0a6cf0;
  --accent-text: #7db4ff;
  --ok: #52d68a;
  --ok-bg: rgba(60, 200, 120, 0.2);
  --warn: #ffc15c;
  --warn-bg: rgba(255, 170, 40, 0.2);
  --bad: #ff8a80;
  --bad-bg: rgba(255, 80, 70, 0.22);
  --info: #7db4ff;
  --info-bg: rgba(60, 140, 255, 0.22);
  --focus: #b9a4ff;
  --bg-a: #0b1022;
  --bg-b: #1a1233;
  --blob1: #1f4fd8;
  --blob2: #7a35d6;
  --blob3: #0c8f78;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --ink: #f1f4ff;
    --ink-2: rgba(241, 244, 255, 0.75);
    --ink-3: rgba(241, 244, 255, 0.55);
    --glass: rgba(34, 38, 62, 0.5);
    --glass-2: rgba(40, 45, 72, 0.72);
    --glass-hover: rgba(52, 58, 92, 0.65);
    --line: rgba(255, 255, 255, 0.12);
    --edge: rgba(255, 255, 255, 0.35);
    --shadow: 0 20px 44px -14px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.3);
    --accent: #3b8bff;
    --accent-2: #0a6cf0;
    --accent-text: #7db4ff;
    --ok: #52d68a;
    --ok-bg: rgba(60, 200, 120, 0.2);
    --warn: #ffc15c;
    --warn-bg: rgba(255, 170, 40, 0.2);
    --bad: #ff8a80;
    --bad-bg: rgba(255, 80, 70, 0.22);
    --info: #7db4ff;
    --info-bg: rgba(60, 140, 255, 0.22);
    --focus: #b9a4ff;
    --bg-a: #0b1022;
    --bg-b: #1a1233;
    --blob1: #1f4fd8;
    --blob2: #7a35d6;
    --blob3: #0c8f78;
    color-scheme: dark;
  }
}

/* Alto contraste: superficies sólidas, bordes firmes */
:root[data-contrast="high"] {
  --ink: #000;
  --ink-2: #000;
  --ink-3: #1a1a1a;
  --glass: #fff;
  --glass-2: #fff;
  --glass-hover: #eef3ff;
  --line: #000;
  --edge: #000;
  --accent: #0033cc;
  --accent-2: #0033cc;
  --accent-text: #0033cc;
  --ok: #004d1f;
  --warn: #5c3000;
  --bad: #8a0000;
  --focus: #c2008a;
  --bg-a: #fff;
  --bg-b: #fff;
  --shadow: none;
}
:root[data-contrast="high"][data-theme="dark"],
:root[data-contrast="high"][data-theme="auto"] {
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root[data-contrast="high"][data-theme="auto"] { color-scheme: light; }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: calc(100% * var(--fscale)); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg-a), var(--bg-b)) fixed;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
:root[data-read="easy"] body {
  font-family: "Atkinson Hyperlegible", Verdana, Tahoma, sans-serif;
  letter-spacing: 0.02em;
  word-spacing: 0.12em;
  line-height: 1.8;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: 1.7rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent-text); }
:root[data-links="on"] a { text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 8px; }
h1[tabindex="-1"]:focus-visible, main[tabindex="-1"]:focus-visible { outline: none; }
:root[data-focus="strong"] :focus-visible { outline-width: 4px; outline-offset: 4px; box-shadow: 0 0 0 7px rgba(255, 255, 255, 0.85); }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 12px; }
.skip:focus { top: 12px; }

/* fondo con manchas de color que se mueven despacio */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg i { position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%; filter: blur(70px); opacity: 0.75; animation: drift 26s ease-in-out infinite alternate; }
.bg i:nth-child(1) { background: var(--blob1); left: -12vmax; top: -10vmax; }
.bg i:nth-child(2) { background: var(--blob2); right: -14vmax; top: 18vh; animation-duration: 32s; animation-delay: -8s; }
.bg i:nth-child(3) { background: var(--blob3); left: 22vw; bottom: -22vmax; animation-duration: 38s; animation-delay: -15s; opacity: 0.6; }
@keyframes drift { to { transform: translate3d(6vmax, 5vmax, 0) scale(1.12); } }
:root[data-contrast="high"] .bg { display: none; }

/* ---------- superficie de vidrio ---------- */
.glass {
  position: relative;
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(190%);
  backdrop-filter: blur(var(--blur)) saturate(190%);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.55), inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}
/* borde de luz tipo "specular" */
.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, var(--edge), rgba(255, 255, 255, 0.04) 38%, rgba(255, 255, 255, 0.04) 62%, var(--edge));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
  opacity: 0.8;
}
.glass.strong { background: var(--glass-2); }
:root[data-contrast="high"] .glass { border: 2px solid #000; box-shadow: none; }
:root[data-contrast="high"] .glass::after { display: none; }

/* sin transparencia: sólido (accesibilidad / equipos lentos) */
:root[data-glass="off"] .glass, :root[data-glass="off"] .glass.strong { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--glass-2); }
:root[data-glass="off"] .bg { display: none; }
@media (prefers-reduced-transparency: reduce) {
  .glass { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--glass-2); }
  .bg { display: none; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--glass-2); }
}

/* ---------- movimiento ---------- */
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- controles ---------- */
.btn {
  --h: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--h); padding: 0 18px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--glass-2); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  transition: transform 0.18s cubic-bezier(0.3, 1.4, 0.5, 1), background 0.2s, box-shadow 0.2s;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 4px 14px -6px rgba(30, 50, 120, 0.35);
  text-decoration: none;
}
.btn:hover { background: var(--glass-hover); transform: translateY(-1px); }
.btn:active { transform: scale(0.96); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.primary { color: #fff; border-color: transparent; background: linear-gradient(180deg, var(--accent), var(--accent-2)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 10px 22px -8px rgba(10, 84, 220, 0.7); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
.btn.ghost:hover { background: var(--glass); }
.btn.sm { --h: 36px; padding: 0 14px; font-size: 0.9rem; }
.btn.icon { width: var(--h); padding: 0; }
.btn.block { width: 100%; }
:root[data-contrast="high"] .btn { border: 2px solid #000; box-shadow: none; }

.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 0.92rem; }
.input {
  width: 100%; min-height: 48px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--glass-2); color: var(--ink); font: inherit;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}
.input:disabled { opacity: 0.55; cursor: not-allowed; }
.input::placeholder { color: var(--ink-3); }
.input:focus-visible { outline-offset: 1px; }
.input-wrap { position: relative; }
.input-wrap .btn { position: absolute; right: 4px; top: 4px; --h: 40px; }
.input-wrap .input { padding-right: 52px; }
:root[data-contrast="high"] .input { border: 2px solid #000; }

.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; color: var(--ink); font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 999px; cursor: pointer; min-height: 40px; }
.seg button[aria-pressed="true"] { background: var(--glass-2); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.6); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; }
.switch button {
  position: relative; width: 56px; height: 34px; flex: none; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--line); transition: background 0.25s;
}
.switch button::after { content: ""; position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); transition: transform 0.25s cubic-bezier(0.3, 1.4, 0.5, 1); }
.switch button[aria-checked="true"] { background: var(--ok); }
.switch button[aria-checked="true"]::after { transform: translateX(22px); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; font-size: 0.82rem; font-weight: 650; border: 1px solid transparent; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.neutral { background: var(--glass); color: var(--ink-2); border-color: var(--line); }

.ico { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); padding: 34px 28px 28px; display: grid; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #4aa3ff, #5b3df5 70%, #b04cff); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 10px 20px -8px rgba(80, 60, 240, 0.7); }
.logo .ico { width: 26px; height: 26px; stroke-width: 2; }
.brand b { font-size: 1.2rem; letter-spacing: -0.02em; }
.form { display: grid; gap: 14px; }
.alert { padding: 12px 14px; border-radius: 14px; font-weight: 600; font-size: 0.92rem; display: flex; gap: 10px; align-items: flex-start; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.info { background: var(--info-bg); color: var(--info); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 272px 1fr; gap: 18px; padding: 18px; min-height: 100vh; }
.side { position: sticky; top: 18px; height: calc(100vh - 36px); padding: 18px 14px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.nav { display: grid; gap: 4px; }
.nav h4 { margin: 14px 12px 4px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--ink-3); }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 16px; color: var(--ink); text-decoration: none; font-weight: 600; min-height: 46px; transition: background 0.2s, transform 0.15s; }
.nav a:hover { background: var(--glass-hover); }
.nav a[aria-current="page"] { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 10px 22px -10px rgba(10, 84, 220, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.4); }
.nav a .soon { margin-left: auto; font-size: 0.68rem; font-weight: 700; opacity: 0.7; }
.main { display: grid; gap: 18px; align-content: start; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 22px; position: sticky; top: 18px; z-index: 5; }
.topbar .grow { flex: 1; min-width: 0; }
.topbar h1 { font-size: 1.35rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 14px; border-radius: 999px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(145deg, #4aa3ff, #b04cff); }
.view { display: grid; gap: 18px; min-width: 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card { padding: 22px; display: grid; gap: 10px; align-content: start; }
.stat .num { font-size: 2rem; font-weight: 750; letter-spacing: -0.03em; }
.stat .label { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-weight: 600; }
.stat .chipico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--accent-text); background: var(--info-bg); }
.hero { padding: 26px 28px; display: grid; gap: 6px; }
.empty { text-align: center; padding: 36px 20px; display: grid; gap: 10px; justify-items: center; }
.empty .ico { width: 44px; height: 44px; color: var(--accent-text); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); padding: 8px 12px; }
.table td { padding: 12px; border-top: 1px solid var(--line); }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.icon-grid div { display: grid; justify-items: center; gap: 6px; padding: 12px 6px; border-radius: 16px; background: var(--glass); font-size: 0.74rem; color: var(--ink-2); }
.icon-grid .ico { width: 26px; height: 26px; color: var(--ink); }

/* ---------- listas y formularios ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar .grow { flex: 1 1 220px; min-width: 0; }
.table-wrap { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.num, .table td.nw { white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn { margin-left: 4px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; }
.pager:empty { display: none; }
.flip { transform: scaleX(-1); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span2 { grid-column: 1 / -1; }
.field .req { color: var(--bad); }
.input.area { padding: 12px 16px; resize: vertical; min-height: 88px; }
select.input { appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 22px) 55%, calc(100% - 16px) 55%; background-size: 6px 6px; background-repeat: no-repeat; }
select.input option { color: #000; }
.row.end { justify-content: flex-end; }
.sheet.wide { width: min(760px, 100%); }
.sub { display: block; font-size: 0.82rem; color: var(--ink-2); }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- accesibilidad: botón flotante + panel ---------- */
.a11y-fab { position: fixed; right: 18px; bottom: 18px; z-index: 40; width: 56px; height: 56px; padding: 0; border-radius: 50%; }
.a11y-fab .ico { width: 28px; height: 28px; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(10, 16, 40, 0.35); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); display: grid; place-items: end center; animation: fade 0.2s; }
.sheet { width: min(480px, 100%); max-height: min(86vh, 760px); overflow: auto; margin: 16px; padding: 22px; display: grid; gap: 6px; animation: rise 0.32s cubic-bezier(0.2, 1.1, 0.4, 1); }
.sheet header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.sheet section { padding: 12px 0; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.sheet section:first-of-type { border-top: 0; }
.sheet .lbl { font-weight: 700; display: flex; align-items: center; gap: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px) scale(0.96); opacity: 0; } }
@media (min-width: 640px) { .sheet-backdrop { place-items: center end; } }

.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; z-index: 60; display: grid; gap: 8px; width: min(440px, calc(100% - 28px)); }
.toast { padding: 14px 18px; display: flex; align-items: center; gap: 10px; font-weight: 600; animation: rise 0.3s; }

/* ---------- responsive: barra inferior estilo iOS ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; padding: 12px 12px 96px; gap: 12px; }
  .side { position: fixed; z-index: 30; left: 12px; right: 12px; bottom: 12px; top: auto; height: auto; padding: 6px; border-radius: 28px; flex-direction: row; overflow: hidden; }
  .side .brand, .side .side-foot { display: none; }
  .nav { grid-auto-flow: column; grid-auto-columns: minmax(64px, 1fr); overflow-x: auto; gap: 2px; width: 100%; scrollbar-width: none; }
  .nav h4, .nav a .soon { display: none; }
  .nav a { flex-direction: column; gap: 2px; padding: 8px 4px; font-size: 0.68rem; border-radius: 20px; min-height: 54px; justify-content: center; text-align: center; }
  .topbar { top: 12px; padding-left: 16px; }
  .a11y-fab { bottom: 104px; width: 52px; height: 52px; }
  .toasts { bottom: 170px; }
  .hide-sm { display: none; }
}
