/* RIVAL — sistema de diseño compartido. Minimalista, oscuro, rojo/negro, toques 3D. */
:root {
  --brand: #e30b1c;
  --brand-2: #ff2a3a;
  --brand-ink: #ffffff;
  --bg: #0a0a0c;
  --bg-2: #101013;
  --surface: #141418;
  --surface-2: #1a1a1f;
  --surface-3: #222228;
  --line: #26262d;
  --line-2: #33333b;
  --text: #f4f4f6;
  --text-2: #b4b4bd;
  --text-3: #7b7b86;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f43f5e;
  --info: #60a5fa;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .7);
  --glow: 0 0 0 1px color-mix(in srgb, var(--brand) 40%, transparent), 0 12px 40px -10px color-mix(in srgb, var(--brand) 55%, transparent);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Chakra Petch", "Inter", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5; }
body { min-height: 100dvh; -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--brand); color: #fff; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -.01em; }
.display { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .14em; }
.eyebrow { font-family: var(--font-display); font-size: 11px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--brand); }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Botones ---------- */
.btn {
  --b: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--b); color: var(--text);
  font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .18s var(--ease), background .18s, border-color .18s, box-shadow .25s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--text-3); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.primary { background: var(--brand); border-color: transparent; color: var(--brand-ink); box-shadow: 0 8px 24px -10px var(--brand); }
.btn.primary:hover { background: var(--brand-2); box-shadow: var(--glow); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.outline { background: transparent; border-color: var(--brand); color: var(--text); }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--bad) 50%, transparent); color: var(--bad); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.lg { min-height: 52px; padding: 0 22px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.icon { width: 42px; padding: 0; }
.btn.sm.icon { width: 34px; }
.btn.loading { pointer-events: none; color: transparent !important; position: relative; }
.btn.loading::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .7s linear infinite; }

/* ---------- Formularios ---------- */
.field { display: grid; gap: 6px; }
.field > span, .label { font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: .02em; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--line-2); color: var(--text); outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
textarea.input { min-height: 88px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); background: var(--surface); }
.input::placeholder { color: var(--text-3); }
.input.big { min-height: 58px; font-size: 20px; font-weight: 700; letter-spacing: .08em; text-align: center; text-transform: uppercase; }
input[type="color"].input { padding: 4px; height: 44px; cursor: pointer; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-form .full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.check input { appearance: none; width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--line-2); background: var(--bg-2); display: grid; place-items: center; transition: .18s; flex: none; margin: 0; }
.check input:checked { background: var(--brand); border-color: var(--brand); }
.check input:checked::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px, -1px); }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); transition: .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .25s var(--ease); }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(18px); }

/* ---------- Tarjetas ---------- */
.card { background: linear-gradient(180deg, var(--surface) 0%, color-mix(in srgb, var(--surface) 70%, var(--bg)) 100%); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; position: relative; }
.card.pad-lg { padding: 26px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h3 { font-size: 16px; font-weight: 700; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-3); }
.tilt { transform-style: preserve-3d; transition: transform .35s var(--ease), box-shadow .35s, border-color .25s; will-change: transform; }
.tilt:hover { border-color: var(--line-2); box-shadow: 0 30px 60px -30px rgba(0,0,0,.9); }

.kpi { display: grid; gap: 6px; }
.kpi .k-label { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); }
.kpi .k-value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .k-foot { font-size: 12px; color: var(--text-3); }
.kpi .k-icon { position: absolute; top: 18px; right: 18px; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); transform: translateZ(30px); }
.kpi .k-icon svg { width: 20px; height: 20px; }

/* ---------- Insignias ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.badge.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.badge.info { color: var(--info); background: color-mix(in srgb, var(--info) 12%, transparent); }
.badge.brand { color: #fff; background: var(--brand); }
.badge.brand::before { background: #fff; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); flex: none; }
.dot.off { background: var(--text-3); box-shadow: none; }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 20%, transparent); }
.pulse { animation: pulse 2s infinite; }

.avatar { width: 38px; height: 38px; border-radius: 11px; flex: none; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: color-mix(in srgb, var(--brand) 22%, var(--surface-2)); color: #ffd6d9; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 96px; height: 96px; border-radius: 24px; font-size: 30px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.table tbody tr.click { cursor: pointer; }
.empty { padding: 40px 16px; text-align: center; color: var(--text-3); font-size: 14px; }
.empty svg { width: 36px; height: 36px; margin: 0 auto 10px; opacity: .5; }

/* ---------- Pestañas / segmentado ---------- */
.seg { display: inline-flex; padding: 4px; gap: 4px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; }
.seg button { border: 0; background: transparent; color: var(--text-2); padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: 13px; cursor: pointer; transition: .18s; white-space: nowrap; }
.seg button.on { background: var(--surface-3); color: var(--text); box-shadow: 0 2px 8px -2px rgba(0,0,0,.6); }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(4, 4, 6, .72); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 16px; animation: fade .2s ease; perspective: 1200px; }
.modal { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-lg); box-shadow: 0 40px 100px -20px rgba(0,0,0,.9); animation: modalIn .38s var(--ease); }
.modal.wide { width: min(820px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.modal-head h3 { font-size: 18px; }
.modal-body { padding: 18px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 22px 22px; flex-wrap: wrap; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 120; right: 16px; bottom: 16px; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: toastIn .35s var(--ease); font-size: 14px; }
.toast.out { animation: toastOut .25s ease forwards; }
.toast .t-bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--info); flex: none; }
.toast.ok .t-bar { background: var(--ok); }
.toast.bad .t-bar { background: var(--bad); }
.toast.warn .t-bar { background: var(--warn); }
.toast b { display: block; margin-bottom: 2px; }

/* ---------- Logo 3D ---------- */
.logo3d { position: relative; width: var(--size, 120px); aspect-ratio: 1000 / 875; transform-style: preserve-3d; animation: float3d 9s ease-in-out infinite; }
.logo3d .layer { position: absolute; inset: 0; }
.logo3d .layer svg { width: 100%; height: 100%; }
.logo3d.static { animation: none; }
.brand-mark { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark .bm-logo { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: #0d0d10; border: 1px solid var(--line-2); box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }
.brand-mark .bm-logo svg { width: 24px; }
.brand-mark .bm-name { font-family: var(--font-display); font-weight: 700; letter-spacing: .28em; font-size: 15px; line-height: 1; }
.brand-mark .bm-sub { font-size: 10px; font-weight: 600; letter-spacing: .16em; color: var(--text-3); text-transform: uppercase; margin-top: 4px; }

/* ---------- Pantalla de acceso (login) ---------- */
.auth-screen { min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { position: relative; overflow: hidden; background: #000; }
.auth-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .55; filter: grayscale(.35) contrast(1.1); transform: scale(1.06); animation: kenburns 24s ease-in-out infinite alternate; }
.auth-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 40%, var(--bg) 100%), linear-gradient(0deg, var(--bg) 0%, transparent 45%), radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--brand) 25%, transparent), transparent 60%); }
.auth-art .art-copy { position: absolute; z-index: 1; left: 48px; bottom: 48px; right: 48px; }
.auth-art .art-copy h2 { font-family: var(--font-display); font-size: clamp(26px, 3vw, 40px); text-transform: uppercase; letter-spacing: .08em; }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; perspective: 1200px; }
.auth-card { width: min(400px, 100%); display: grid; gap: 22px; animation: rise .7s var(--ease) both; }
.auth-card h1 { font-size: 28px; }
.pw-wrap { position: relative; }
.pw-wrap .btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-height: 36px; width: 36px; }

/* ---------- Animaciones ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.fade-in { animation: rise .55s var(--ease) both; }
.stagger > * { animation: rise .55s var(--ease) both; }
.stagger > *:nth-child(2) { animation-delay: .05s; }
.stagger > *:nth-child(3) { animation-delay: .1s; }
.stagger > *:nth-child(4) { animation-delay: .15s; }
.stagger > *:nth-child(5) { animation-delay: .2s; }
.stagger > *:nth-child(6) { animation-delay: .25s; }
.stagger > *:nth-child(n+7) { animation-delay: .3s; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; min-height: 14px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) rotateX(10deg) scale(.97); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 40%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes kenburns { to { transform: scale(1.16) translate(-2%, -1%); } }
@keyframes float3d { 0%, 100% { transform: rotateY(-24deg) rotateX(8deg) translateY(0); } 50% { transform: rotateY(24deg) rotateX(-4deg) translateY(-8px); } }
@keyframes scanline { 0% { top: 8%; } 50% { top: 86%; } 100% { top: 8%; } }

@media (max-width: 860px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-art { position: fixed; inset: 0; }
  .auth-art img { opacity: .35; }
  .auth-art .art-copy { display: none; }
  .auth-panel { position: relative; z-index: 1; }
  .grid-form { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .reveal { opacity: 1; transform: none; }
}
