:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #6b7280;
    --line: #e5eaf1;
    --primary: #7b1e3a;
    --primary-dark: #5e142b;
    --green: #12805c;
    --amber: #b7791f;
    --red: #bd2c3a;
    --blue: #285ea8;
    --shadow: 0 12px 35px rgba(22, 35, 60, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); font-family: Poppins, system-ui, sans-serif; font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
button, input, select { font: inherit; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 28px; min-height: 76px; padding: 0 4vw; color: #fff; background: linear-gradient(120deg, #33101c, #7b1e3a); box-shadow: 0 8px 24px rgba(44, 8, 21, .22); }
.brand { display: inline-flex; align-items: center; gap: 11px; color: #fff; white-space: nowrap; }
.brand-mark { display: inline-grid; place-items: center; width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.4); border-radius: 13px; color: #fff; background: rgba(255,255,255,.12); font-weight: 700; letter-spacing: -.5px; }
.brand strong, .brand small, .auth-brand strong, .auth-brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { color: rgba(255,255,255,.67); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; }
.nav { display: flex; align-items: stretch; gap: 5px; margin-left: auto; }
.nav-link { display: inline-flex; align-items: center; min-height: 76px; padding: 0 13px; border: 0; color: rgba(255,255,255,.72); background: transparent; font-size: 13px; cursor: pointer; }
.nav-link:hover, .nav-link.active { color: #fff; }
.nav-link.active { box-shadow: inset 0 -3px #fff; }
.logout-form { display: flex; }
.menu-toggle { display: none; margin-left: auto; padding: 8px 12px; border: 1px solid rgba(255,255,255,.25); border-radius: 8px; color: #fff; background: transparent; }

.container { width: min(1220px, 92vw); margin: 34px auto 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head h1, .section-title { margin: 0; font-size: clamp(22px, 2.4vw, 32px); letter-spacing: -.8px; }
.page-head p { margin: 7px 0 0; color: var(--muted); }
.head-actions { display: flex; flex-wrap: wrap; gap: 9px; }

.grid { display: grid; gap: 20px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats { margin-bottom: 22px; }
.card { padding: 22px; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .7px; text-transform: uppercase; }
.stat-value { margin-top: 9px; font-size: 28px; font-weight: 700; letter-spacing: -1px; }
.stat-note { margin-top: 5px; color: var(--muted); font-size: 12px; }
.card h2 { margin: 0 0 16px; font-size: 18px; }
.card p:last-child { margin-bottom: 0; }
.stack { display: grid; gap: 15px; }
.credential-box { border-left: 4px solid var(--green); }
.credential-box.warning { border-left-color: var(--amber); }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 16px; border: 1px solid transparent; border-radius: 10px; font-weight: 600; cursor: pointer; transition: .2s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--primary); }
.button-primary:hover { color: #fff; background: var(--primary-dark); }
.button-secondary { color: var(--text); border-color: var(--line); background: #fff; }
.button-secondary:hover { color: var(--primary); border-color: #cbd2dd; }
.button-danger { color: var(--red); border-color: #f1cbd0; background: #fff7f8; }
.button-small { min-height: 32px; padding: 5px 10px; border-radius: 8px; font-size: 12px; }
.button-full { width: 100%; }

label { display: grid; gap: 7px; color: #3b4558; font-size: 12px; font-weight: 600; }
input, select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #d8dee8; border-radius: 9px; color: var(--text); background: #fff; outline: none; }
input:focus, select:focus { border-color: #9d4c66; box-shadow: 0 0 0 3px rgba(123,30,58,.09); }
.form-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-actions { display: flex; gap: 9px; align-items: end; }
.inline-form { display: inline-flex; gap: 7px; align-items: center; }
.muted { color: var(--muted); }
.help { margin-top: 7px; color: var(--muted); font-size: 12px; line-height: 1.6; }

.alert { margin-bottom: 16px; padding: 13px 15px; border: 1px solid; border-radius: 11px; line-height: 1.5; }
.alert-success { color: #0b6547; border-color: #b7e2d2; background: #eefaf6; }
.alert-error { color: #9c2030; border-color: #efc1c7; background: #fff3f5; }
.alert-warning { color: #8a5b12; border-color: #ecd6aa; background: #fff9eb; }
.alert-info { color: #24578e; border-color: #bfd6ee; background: #f1f7fd; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 14px; color: #637086; background: #f8fafc; font-size: 11px; letter-spacing: .5px; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fbfcfe; }
.nowrap { white-space: nowrap; }
.uuid { color: #586479; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; }
.amount { font-weight: 600; text-align: right; white-space: nowrap; }
.empty { padding: 42px 20px; color: var(--muted); text-align: center; }

.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-finished, .badge-vigente { color: #0d6a4b; background: #e5f7f0; }
.badge-processing, .badge-submitted { color: #245c9a; background: #eaf3fd; }
.badge-queued { color: #7b5a12; background: #fff5d8; }
.badge-no_data { color: #596274; background: #eef1f5; }
.badge-error, .badge-cancelado { color: #a62534; background: #fdecef; }
.badge-desconocido { color: #6b7280; background: #eef1f5; }

.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 20px; }
.pagination a, .pagination span { display: grid; place-items: center; min-width: 36px; min-height: 36px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.pagination .current { color: #fff; border-color: var(--primary); background: var(--primary); }
.request-message { max-width: 380px; color: var(--muted); font-size: 12px; }
.footer { width: min(1220px, 92vw); margin: 0 auto; padding: 20px 0 32px; color: #939bab; font-size: 11px; text-align: center; }

.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 30px 15px; background: radial-gradient(circle at top, #8d3652 0, #4c1728 38%, #260b14 100%); }
.auth-card { width: min(440px, 100%); padding: 32px; border: 1px solid rgba(255,255,255,.18); border-radius: 20px; background: #fff; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 25px; }
.auth-brand .brand-mark { color: var(--primary); border-color: #e4c9d2; background: #f9eef2; }
.auth-brand strong { font-size: 17px; }
.auth-brand small { color: var(--muted); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
.auth-card h1 { margin: 0 0 8px; font-size: 25px; }
.auth-card form { display: grid; gap: 15px; margin-top: 22px; }

@media (max-width: 950px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .menu-toggle { display: block; }
    .nav { position: absolute; top: 67px; right: 4vw; display: none; width: min(300px, 92vw); padding: 10px; border-radius: 13px; background: #451322; box-shadow: 0 20px 45px rgba(0,0,0,.25); }
    .nav.open { display: grid; }
    .nav-link { min-height: 44px; padding: 8px 12px; border-radius: 8px; }
    .nav-link.active { background: rgba(255,255,255,.11); box-shadow: none; }
}

@media (max-width: 680px) {
    .topbar { min-height: 67px; padding: 0 18px; }
    .brand-mark { width: 38px; height: 38px; }
    .container { width: min(94vw, 1220px); margin-top: 24px; }
    .page-head { align-items: flex-start; flex-direction: column; }
    .grid-4, .grid-2, .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .card { padding: 18px; border-radius: 14px; }
    .head-actions, .form-actions { width: 100%; }
    .head-actions .button, .form-actions .button { flex: 1; }
    .auth-card { padding: 25px 20px; }
}
