:root {
  --azul-oscuro: #0d47c9;
  --azul: #1267f5;
  --ciano: #11d6e6;
  --texto: #1f2937;
  --gris: #64748b;
  --fondo: #f4f7fb;
  --borde: #e2e8f0;
  --verde: #16a34a;
  --rojo: #dc2626;
  --ambar: #d97706;
  --radio: 16px;
  --sombra: 0 10px 30px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Poppins', sans-serif;
  background: var(--fondo);
  color: var(--texto);
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ---------- Login ---------- */
.login-page { display: flex; min-height: 100vh; }
.login-left {
  flex: 1.1;
  position: relative;
  background: linear-gradient(135deg, #0d47c9 0%, #0ea5e9 55%, #11d6e6 100%);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; padding: 40px;
}
.login-left::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.14), transparent 24%),
    radial-gradient(circle at 82% 18%, rgba(255,255,255,.10), transparent 20%),
    radial-gradient(circle at 70% 82%, rgba(255,255,255,.08), transparent 16%);
}
.login-left-content { position: relative; z-index: 2; color: #fff; max-width: 460px; }
.login-left-content h1 { font-size: clamp(28px, 3.4vw, 44px); font-weight: 900; line-height: 1.15; margin-bottom: 14px; }
.login-left-content p { color: rgba(255,255,255,.9); font-weight: 300; font-size: 16px; }
.login-brand-mark {
  display: flex; align-items: center; gap: 12px; margin-bottom: 26px;
}
.login-logo-badge {
  width: 56px; height: 56px; border-radius: 16px;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.3);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
.login-logo-badge svg { width: 32px; height: 32px; }
.login-brand-name { font-size: 20px; font-weight: 800; letter-spacing: .4px; }

.login-right {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px;
}
.login-card {
  width: min(420px, 100%);
  background: #fff; border: 1px solid var(--borde);
  border-radius: 22px; padding: 34px 32px;
  box-shadow: var(--sombra);
}
.login-card h2 { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.login-card .login-sub { color: var(--gris); font-size: 14px; margin-bottom: 24px; }
.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-size: 12px; font-weight: 700; color: var(--gris); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .05em; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 12px 14px; font-size: 14px;
  border: 1.5px solid var(--borde); border-radius: 12px;
  background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--azul); box-shadow: 0 0 0 3px rgba(18, 103, 245, .12);
}
.btn {
  border: none; border-radius: 12px; padding: 12px 20px;
  font-size: 14px; font-weight: 700; transition: transform .12s, box-shadow .12s, opacity .12s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: wait; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--azul), var(--ciano));
  color: #fff; width: 100%;
  box-shadow: 0 10px 22px rgba(18, 103, 245, .28);
}
.btn-secundario { background: #eff6ff; color: var(--azul); border: 1px solid #dbeafe; }
.btn-verde { background: linear-gradient(135deg, #16a34a, #4ade80); color: #fff; box-shadow: 0 10px 22px rgba(22,163,74,.28); }
.btn-rojo { background: #fef2f2; color: var(--rojo); border: 1px solid #fecaca; }
.btn-ghost { background: transparent; color: var(--gris); border: 1px solid var(--borde); }

.alert {
  padding: 12px 14px; border-radius: 12px; font-size: 13.5px; font-weight: 600; margin-bottom: 16px;
}
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ---------- Layout app ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-top {
  position: relative; background: linear-gradient(135deg, #0d47c9 0%, #0ea5e9 55%, #11d6e6 100%);
  padding: 18px 26px; color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.app-top::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 15% 0%, rgba(255,255,255,.12), transparent 30%);
}
.app-brand { display: flex; align-items: center; gap: 12px; position: relative; z-index: 2; }
.app-brand svg { width: 38px; height: 38px; }
.app-brand strong { font-size: 18px; font-weight: 800; letter-spacing: .3px; }
.app-userbox {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 12px;
  background: rgba(0,0,0,.22); padding: 8px 12px; border-radius: 14px; font-size: 13px; font-weight: 600;
}
.app-userbox a { color: #fff; text-decoration: none; border: 1px solid rgba(255,255,255,.6); padding: 4px 10px; border-radius: 9px; font-size: 12px; }
.app-userbox a:hover { background: #fff; color: #0f172a; }

.app-body { width: min(1180px, 94vw); margin: 26px auto 50px; flex: 1; }

/* ---------- Menú ---------- */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.menu-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  background: #fff; border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 22px; text-decoration: none; color: var(--texto);
  transition: transform .15s, box-shadow .15s;
}
.menu-card:hover { transform: translateY(-3px); box-shadow: var(--sombra); }
.menu-card .icon {
  width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 24px;
}
.menu-card.green .icon { background: linear-gradient(135deg, #16a34a, #4ade80); }
.menu-card.purple .icon { background: linear-gradient(135deg, #7c3aed, #c084fc); }
.menu-card.blue .icon { background: linear-gradient(135deg, var(--azul), var(--ciano)); }
.menu-card.orange .icon { background: linear-gradient(135deg, #d97706, #fbbf24); }
.menu-card.slate .icon { background: linear-gradient(135deg, #475569, #94a3b8); }
.menu-card.pink .icon { background: linear-gradient(135deg, #db2777, #f472b6); }
.menu-card .card-title { font-size: 16px; font-weight: 800; }
.menu-card .card-sub { font-size: 12.5px; color: var(--gris); }

/* ---------- Títulos de sección ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 24px; font-weight: 800; }
.page-head .crumb { font-size: 13px; color: var(--gris); margin-bottom: 2px; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Tarjetas / formularios ---------- */
.card { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 22px; box-shadow: var(--sombra); }
.card + .card { margin-top: 18px; }
.card h3 { font-size: 15px; font-weight: 800; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.card h3 .badge { font-size: 10px; background: #eff6ff; color: var(--azul); padding: 3px 8px; border-radius: 999px; font-weight: 700; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }

/* ---------- Tabla items ---------- */
.items-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.items-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--gris); padding: 8px 6px; border-bottom: 2px solid var(--borde);
}
.items-table td { padding: 6px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.items-table input, .items-table select {
  width: 100%; padding: 8px 9px; font-size: 13px; border: 1.5px solid var(--borde); border-radius: 8px; outline: none;
}
.items-table input:focus, .items-table select:focus { border-color: var(--azul); }
.items-table .num { text-align: right; }
.row-remove {
  background: #fef2f2; color: var(--rojo); border: 1px solid #fecaca;
  width: 30px; height: 30px; border-radius: 8px; font-weight: 800;
}

.btn-add-item { margin-top: 12px; }

/* ---------- Resumen ---------- */
.resumen-box { background: #f8fafc; border: 1px solid var(--borde); border-radius: 14px; padding: 16px 18px; }
.resumen-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; color: var(--gris); border-bottom: 1px dashed #e2e8f0; }
.resumen-row.total { font-weight: 800; color: var(--texto); font-size: 18px; border-bottom: none; padding-top: 12px; }
.resumen-row.total span:last-child { color: var(--azul); }

/* ---------- Tablas de listados ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--gris); padding: 10px 8px; border-bottom: 2px solid var(--borde);
}
.data-table td { padding: 10px 8px; border-bottom: 1px solid #f1f5f9; }
.data-table tr:hover td { background: #f8fafc; }

.badge-estado { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge-estado.PROCESADO { background: #f0fdf4; color: #15803d; }
.badge-estado.SIMULADO { background: #fffbeb; color: #92400e; }
.badge-estado.RECHAZADO { background: #fef2f2; color: #991b1b; }
.badge-estado.ERROR { background: #fef2f2; color: #991b1b; }
.badge-estado.ANULADO { background: #f1f5f9; color: #475569; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal {
  background: #fff; border-radius: 18px; max-width: 820px; width: 100%;
  max-height: 90vh; overflow: auto; padding: 24px;
  box-shadow: 0 30px 60px rgba(15,23,42,.3);
}
.modal h3 { font-size: 18px; font-weight: 800; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; flex-wrap: wrap; }

pre.json-view {
  background: #0f172a; color: #a5f3fc; border-radius: 12px; padding: 14px;
  font-size: 12px; overflow: auto; max-height: 380px; font-family: ui-monospace, Consolas, monospace;
  white-space: pre-wrap; word-break: break-word;
}

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; box-shadow: 0 16px 30px rgba(15,23,42,.35);
  animation: toast-in .25s ease;
}
.toast.success { border-left: 4px solid #4ade80; }
.toast.error { border-left: 4px solid #f87171; }
.toast.info { border-left: 4px solid #38bdf8; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Config secciones ---------- */
.config-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.config-item { background: #fff; border: 1px solid var(--borde); border-radius: 14px; padding: 16px 18px; }
.config-item .cfg-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--gris); font-weight: 700; }
.config-item .cfg-value { font-size: 17px; font-weight: 800; margin-top: 4px; }
.cfg-ok { color: var(--verde); }
.cfg-warn { color: var(--ambar); }

.file-drop {
  border: 2px dashed var(--borde); border-radius: 14px; padding: 26px; text-align: center;
  color: var(--gris); font-size: 13.5px; cursor: pointer; transition: border-color .15s, background .15s;
}
.file-drop:hover, .file-drop.dragover { border-color: var(--azul); background: #eff6ff; }

/* ---------- Helpers ---------- */
.text-gris { color: var(--gris); }
.small { font-size: 12px; }
.mt { margin-top: 16px; }
.mt8 { margin-top: 8px; }
.mb { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.center { text-align: center; }
.hidden { display: none !important; }

@media (max-width: 760px) {
  .login-left { display: none; }
  .app-top { padding: 14px 16px; }
}
