@layer componentes {
  .nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--nav-bg);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    transition: box-shadow 0.25s ease;
  }
  .nav.scrolled { box-shadow: var(--e-2); }
  .nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
  .nav-links { display: flex; align-items: center; gap: 6px; }
  .nav-links .link { display: none; padding: 8px 12px; color: var(--text-2); font-size: 15px; font-weight: 500; border-radius: var(--r-sm); }
  .nav-links .link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
  @media (min-width: 860px) { .nav-links .link { display: inline-block; } }

  .logo { display: inline-flex; align-items: center; }
  .logo img { height: 28px; width: auto; }
  .logo .logo-dark { display: none; }
  :root[data-theme="dark"] .logo .logo-light { display: none; }
  :root[data-theme="dark"] .logo .logo-dark { display: block; }

  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 42px; padding: 0 18px; border-radius: var(--r);
    font-weight: 600; font-size: 15px; line-height: 1;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    cursor: pointer; white-space: nowrap; box-shadow: var(--e-1);
    transition: transform 0.12s ease, background-color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  }
  .btn:hover { text-decoration: none; border-color: color-mix(in srgb, var(--text) 18%, transparent); }
  .btn:active { transform: translateY(1px); }
  .btn-primary { background: var(--brand); border-color: transparent; color: var(--brand-ink); box-shadow: var(--e-1); }
  .btn-primary:hover { background: color-mix(in srgb, var(--brand) 90%, #000); border-color: transparent; box-shadow: 0 8px 18px color-mix(in srgb, var(--brand) 24%, transparent); transform: translateY(-1px); }
  .btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
  .btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
  .btn-lg { height: 50px; padding: 0 24px; font-size: 16px; border-radius: var(--r); }
  .btn-block { width: 100%; }
  .btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
  .btn svg { width: 18px; height: 18px; flex: none; }

  .icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: var(--r); border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
  .icon-btn:hover { background: var(--surface-2); color: var(--text); }
  .icon-btn svg { width: 19px; height: 19px; }
  .theme-toggle .sun { display: none; }
  :root[data-theme="dark"] .theme-toggle .sun { display: block; }
  :root[data-theme="dark"] .theme-toggle .moon { display: none; }

  .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--e-2); }
  .eyebrow { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--brand-text); }

  .field { display: grid; gap: 6px; }
  .field label { font-size: 14px; font-weight: 550; color: var(--text-2); }
  .input {
    width: 100%; height: 44px; padding: 0 14px; border-radius: var(--r);
    border: 1px solid var(--border); background: var(--bg-elev); color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }
  .input::placeholder { color: var(--muted); }
  .input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }

  .footer { padding: 40px 0 56px; color: var(--muted); font-size: 14px; }
  .footer-inner { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 28px; }
  @media (max-width: 520px) {
    .nav-links .btn-ghost { display: none; }
    .nav-links .btn { height: 38px; padding: 0 14px; }
  }
  .nav-links .link[aria-current="page"] { color: var(--text); }
  .nav-inner > .nav-burger { display: inline-grid; margin-left: -10px; }
  .nav-menu { display: grid; padding-bottom: 12px; }
  .nav-menu a { padding: 12px 4px; color: var(--text); font-weight: 550; border-top: 1px solid var(--border); }
  .nav-menu a:hover { text-decoration: none; color: var(--brand-text); }
  @media (min-width: 860px) { .nav-inner > .nav-burger, .nav-menu { display: none !important; } }
  .nav-links { margin-left: auto; }

  .modal { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 0; width: min(560px, calc(100vw - 24px)); background: var(--surface); color: var(--text); box-shadow: var(--e-3); }
  .modal::backdrop { background: var(--overlay); backdrop-filter: blur(3px); }
  .modal[open] { animation: dialog-in var(--d) var(--ease-out) both; }
  .modal[open]::backdrop { animation: fade-in var(--d) var(--ease-out) both; }
  .modal.closing { animation: dialog-out 160ms var(--ease-out) both; }
  .modal.closing::backdrop { animation: fade-out 160ms var(--ease-out) both; }
  @keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
  @keyframes dialog-out { to { opacity: 0; transform: translateY(6px) scale(.985); } }
  @keyframes fade-in { from { opacity: 0; } }
  @keyframes fade-out { to { opacity: 0; } }
  .modal-head { display: flex; justify-content: space-between; align-items: center; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); }
  .modal-head h2 { font-size: 17px; }
  .modal-body { padding: var(--s-5); max-height: 70vh; overflow-y: auto; }
  .modal-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
  .modal-foot .btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
  :root[data-theme="dark"] .modal-foot .btn-danger { color: #1a0306; }
  .confirm .modal-head { border-bottom: 0; padding-bottom: 0; }
  .confirm-title { display: flex; align-items: center; gap: var(--s-3); }
  .confirm-icon { width: 40px; height: 40px; border-radius: var(--r); display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); animation: pop var(--d-slow) var(--ease-spring) both; }
  .confirm.is-danger .confirm-icon { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
  .confirm-icon svg { width: 20px; height: 20px; }
  .confirm-note { margin-top: var(--s-3); color: var(--muted); font-size: var(--t-sm); font-weight: 600; }
  .confirm.is-danger .confirm-note { color: var(--danger); }
  @keyframes pop { from { transform: scale(.6); opacity: 0; } }
  .diff { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
  .diff li { display: grid; grid-template-columns: minmax(110px, auto) 1fr auto 1fr; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); background: var(--surface-2); font-size: var(--t-sm); }
  .diff-campo { color: var(--muted); font-weight: 600; }
  .diff-antes { color: var(--text-2); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--danger) 60%, transparent); overflow-wrap: anywhere; }
  .diff-despues { color: var(--text); overflow-wrap: anywhere; }
  .diff svg { width: 16px; height: 16px; color: var(--accent); }
  @media (max-width: 520px) { .diff li { grid-template-columns: 1fr auto 1fr; } .diff-campo { grid-column: 1 / -1; } }

  .toasts { position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--s-2); align-items: flex-end; pointer-events: none; }
  .toast { position: relative; overflow: hidden; pointer-events: auto; display: flex; align-items: center; gap: var(--s-3); background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: var(--r); font-size: var(--t-sm); font-weight: 500; box-shadow: var(--e-3); animation: toast-in var(--d-slow) var(--ease-spring) both; max-width: 420px; }
  .toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
  .toast.err::before { background: var(--danger); }
  .toast.info::before { background: var(--info); }
  .toast-act { border: 0; background: none; color: #0b6e63; font-weight: 700; cursor: pointer; padding: 2px 4px; border-radius: var(--r-sm); }
  :root:not([data-theme="dark"]) .toast-act { color: #7ff0dd; }
  .toast-act:hover { text-decoration: underline; }
  .toast-time { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: color-mix(in srgb, var(--bg) 35%, transparent); transform-origin: left; animation: toast-time var(--ms, 4000ms) linear both; }
  .toast.out { animation: toast-out 220ms var(--ease-out) both; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
  @keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
  @keyframes toast-time { to { transform: scaleX(0); } }

  .btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
  .btn[aria-busy="true"]::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--brand-ink) transparent var(--brand-ink) var(--brand-ink); animation: spin .7s linear infinite; opacity: .9; }
  .btn:not(.btn-primary)[aria-busy="true"]::after { border-color: var(--text) transparent var(--text) var(--text); }
  @keyframes spin { to { transform: rotate(360deg); } }

  .skeleton { display: block; height: 12px; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface-2) 0%, color-mix(in srgb, var(--surface-2) 40%, var(--surface)) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
  @keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
  .sk { display: grid; gap: var(--s-5); animation: fade-in var(--d) var(--ease-out) 120ms both; }
  .sk-head { display: grid; gap: var(--s-2); }
  .sk-head .skeleton:first-child { width: 220px; height: 26px; }
  .sk-head .skeleton:last-child { width: 320px; max-width: 80%; }
  .sk-tabla { padding: var(--s-2) var(--s-4); }
  .sk-fila { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: var(--s-5); padding: var(--s-4) 0; border-bottom: 1px solid var(--border); }
  .sk-fila:last-child { border-bottom: 0; }
  .sk-tarjetas, .sk-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s-4); }
  .sk-tarjeta { padding: var(--s-5); display: grid; gap: var(--s-3); }
  .sk-tarjeta .skeleton:nth-child(2) { height: 24px; width: 60%; }
  .sk-tarjeta .skeleton:nth-child(3) { width: 40%; }
  .sk-form { padding: var(--s-5); display: grid; gap: var(--s-4); }
  .sk-form .skeleton { height: 40px; }
  .error-state .empty-icon { width: 44px; height: 44px; border-radius: var(--r); display: grid; place-items: center; background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
  .error-state .empty-icon svg { width: 22px; height: 22px; }

  @media (max-width: 960px) {
    .toasts { bottom: 84px; left: var(--s-4); right: var(--s-4); align-items: stretch; }
    .toast { max-width: none; }
  }
  @media (max-width: 640px) {
    .modal { margin: auto auto 0; width: 100vw; max-width: 100vw; border-radius: var(--r-lg) var(--r-lg) 0 0; }
    @keyframes dialog-in { from { transform: translateY(40px); } }
  }
}
@layer componentes {
  .cmd { width: min(640px, calc(100vw - 24px)); margin: 12vh auto auto; padding: 0; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--text); box-shadow: var(--e-3); overflow: hidden; }
  .cmd::backdrop { background: var(--overlay); backdrop-filter: blur(4px); }
  .cmd[open] { animation: dialog-in var(--d) var(--ease-out) both; }
  .cmd.closing { animation: dialog-out 140ms var(--ease-out) both; }
  .cmd-head { display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-4); border-bottom: 1px solid var(--border); }
  .cmd-head svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
  .cmd-input { flex: 1; height: 56px; border: 0; outline: none; background: none; font-size: var(--t-lg); color: var(--text); }
  .cmd-input::-webkit-search-cancel-button { display: none; }
  .cmd-lista { list-style: none; margin: 0; padding: var(--s-2); max-height: min(60vh, 440px); overflow-y: auto; }
  .cmd-lista li { display: flex; align-items: center; gap: var(--s-3); padding: 10px 12px; border-radius: var(--r-sm); cursor: pointer; }
  .cmd-lista li.on { background: var(--brand-soft); }
  .cmd-lista li.on .cmd-ic { background: var(--brand); color: var(--brand-ink); }
  .cmd-ic { width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; transition: background-color var(--d-fast), color var(--d-fast); }
  .cmd-ic svg { width: 17px; height: 17px; }
  .cmd-label { flex: 1; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cmd-hint { color: var(--muted); font-size: var(--t-xs); white-space: nowrap; }
  .cmd-vacio { justify-content: center; color: var(--muted); cursor: default; }
}
@layer componentes {
  .modal.sheet { margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(520px, 100vw); border-radius: var(--r-lg) 0 0 var(--r-lg); border-right: 0; display: flex; flex-direction: column; }
  .modal.sheet[open] { animation: sheet-in var(--d-slow) var(--ease-out) both; }
  .modal.sheet.closing { animation: sheet-out 160ms var(--ease-out) both; }
  .modal.sheet .modal-body { flex: 1; max-height: none; }
  .modal.sheet .modal-foot { border-radius: 0 0 0 var(--r-lg); }
  @keyframes sheet-in { from { transform: translateX(100%); } }
  @keyframes sheet-out { to { transform: translateX(100%); opacity: .6; } }
  .revision { display: grid; gap: var(--s-4); animation: fade-in var(--d) var(--ease-out) both; }
  .revision-aviso { display: flex; align-items: center; gap: var(--s-2); color: var(--text-2); font-weight: 600; }
  .revision-aviso svg { width: 18px; height: 18px; color: var(--brand-text); }
  @media (max-width: 640px) {
    .modal.sheet { width: 100vw; border-radius: 0; }
    .modal.sheet .modal-foot { border-radius: 0; }
  }
}
