:root {
  --fondo: #0d0f2b;
  --superficie: #161a42;
  --superficie-alta: #1f2457;
  --borde: #2d3375;
  --acento: #ff5fc8;
  --acento-suave: #7c6cff;
  --texto: #edeeff;
  --suave: #a3a7d6;
  --ok: #3ddc97;
  --aviso: #ffc857;
  --error: #ff6b6b;
}
@media (prefers-color-scheme: light) {
  :root { --fondo: #f4f5ff; --superficie: #fff; --superficie-alta: #eceeff; --borde: #cfd3f5; --texto: #14163a; --suave: #55598c; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fondo); color: var(--texto); font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
a { color: var(--acento-suave); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
.muted { color: var(--suave); }
header.bar { display: flex; align-items: center; gap: 1rem; padding: .75rem 1rem; background: var(--superficie); border-bottom: 1px solid var(--borde); flex-wrap: wrap; }
header.bar .brand { font-weight: 700; display: flex; align-items: center; gap: .5rem; }
header.bar .brand img { height: 28px; width: auto; border-radius: 6px; }
header.bar nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
header.bar nav a { color: var(--suave); text-decoration: none; padding: .4rem .7rem; border-radius: 8px; }
header.bar nav a.current, header.bar nav a:hover { background: var(--superficie-alta); color: var(--texto); }
main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.card { background: var(--superficie); border: 1px solid var(--borde); border-radius: 14px; padding: 1rem 1.1rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.stat .n { font-size: 1.9rem; font-weight: 700; }
.stat .t { color: var(--suave); font-size: .9rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 180px; }
.row > .auto { flex: 0 0 auto; }
label.field { display: block; margin-bottom: .75rem; }
label.field .label { display: block; font-size: .9rem; color: var(--suave); margin-bottom: .25rem; }
label.field .hint { display: block; font-size: .8rem; color: var(--suave); margin-top: .2rem; }
input, select, textarea { width: 100%; padding: .6rem .7rem; border-radius: 10px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); font: inherit; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--acento-suave); outline-offset: 2px; }
button, .btn { display: inline-block; padding: .6rem 1rem; border: 0; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; color: #fff; background: linear-gradient(135deg, var(--acento-suave), var(--acento)); text-decoration: none; }
button.secondary, .btn.secondary { background: var(--superficie-alta); color: var(--texto); border: 1px solid var(--borde); }
button.danger { background: #b3363f; }
button.small { padding: .3rem .6rem; font-size: .85rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--borde); vertical-align: top; }
th { color: var(--suave); font-weight: 600; white-space: nowrap; }
td code, code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .88em; background: var(--superficie-alta); padding: .1rem .35rem; border-radius: 5px; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; background: var(--superficie-alta); border: 1px solid var(--borde); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--aviso); border-color: var(--aviso); }
.auth { max-width: 420px; margin: 8vh auto; }
.auth h1 { text-align: center; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { padding: .4rem .8rem; border-radius: 8px; color: var(--suave); text-decoration: none; border: 1px solid transparent; }
.tabs a.current { background: var(--superficie-alta); color: var(--texto); border-color: var(--borde); }
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 10; max-width: min(92vw, 380px); }
.toast { background: var(--superficie-alta); border: 1px solid var(--borde); border-left: 4px solid var(--ok); padding: .6rem .9rem; border-radius: 10px; }
.toast.error { border-left-color: var(--error); }
.empty { text-align: center; padding: 2rem 1rem; }
.logo-preview { max-height: 96px; max-width: 100%; background: #fff2; border-radius: 10px; padding: .4rem; }
.total { font-size: 1.3rem; font-weight: 700; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; }
dl.kv dt { color: var(--suave); }
dl.kv dd { margin: 0; word-break: break-word; }
@media (max-width: 600px) { main { padding: 1rem .75rem 4rem; } th, td { padding: .4rem; } }
.pad { padding: 1rem; }
[hidden] { display: none !important; }

/* Indicadores de espera: botones ocupados y barra de carga */
button.loading { position: relative; padding-right: 2.6rem; opacity: 0.85; cursor: progress; }
button.loading::after {
  content: ''; position: absolute; right: 0.9rem; top: 50%; width: 1rem; height: 1rem; margin-top: -0.5rem;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 20; transform-origin: left center;
  background: linear-gradient(90deg, var(--acento-suave), var(--acento)); animation: progress 1.1s ease-in-out infinite;
}
@keyframes progress { 0% { transform: scaleX(0.05); opacity: 1; } 60% { transform: scaleX(0.8); opacity: 1; } 100% { transform: scaleX(1); opacity: 0.2; } }
@media (prefers-reduced-motion: reduce) {
  button.loading::after { animation-duration: 2s; }
  #progress { animation: none; transform: none; opacity: 0.7; }
}
