:root {
  /* Marca FRACTAI */
  --blue-deep: #0E2238;       /* navy de sidebar / login */
  --blue-deep-2: #0A1A2C;
  --sky: #2563EB;             /* azul primario (botones, activo) */
  --sky-dark: #1D4ED8;
  --cyan: #3B82F6;            /* azul medio */
  --cyan-light: #60A5FA;      /* azul claro (acento "AI") */

  --green: #10B981;
  --green-bg: #DCFCE7;
  --green-text: #047857;
  --amber: #F59E0B;
  --amber-bg: #FEF3C7;
  --amber-text: #B45309;
  --violet: #8B5CF6;
  --violet-bg: #EDE9FE;
  --red: #EF4444;
  --red-bg: #FEE2E2;
  --red-border: #FECACA;
  --red-text: #DC2626;

  --white: #FFFFFF;
  --fog: #EEF2F8;
  --border: #E5E9F1;
  --border-soft: #EEF1F7;
  --text-1: #0F1B2D;
  --text-2: #5B6B82;
  --text-3: #97A3B5;

  --radius-sm: 8px;
  --radius: 11px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(16,30,54,.04), 0 4px 14px rgba(16,30,54,.05);
  --shadow-md: 0 8px 30px rgba(16,30,54,.12);
  --sidebar-w: 252px;
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --display: 'Poppins', 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--fog);
  color: var(--text-1);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1 { font-family: var(--display); font-size: 26px; font-weight: 600; letter-spacing: -0.4px; }
h2 { font-family: var(--display); font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
h3 { font-family: var(--display); font-size: 18px; font-weight: 600; }
a { color: var(--sky); text-decoration: none; font-weight: 500; }
a:hover { color: var(--sky-dark); }
button { font-family: inherit; }
[data-lucide] { width: 20px; height: 20px; stroke-width: 1.75; }

/* ===== Logo ===== */
.logo-mark { width: 34px; height: 34px; flex-shrink: 0; display: block; }
.logo-mark.sm { width: 28px; height: 28px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 20px; border-radius: var(--radius);
  font-size: 14.5px; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--sky); color: #fff; box-shadow: 0 6px 16px rgba(37,99,235,.26); }
.btn-primary:hover:not(:disabled) { background: var(--sky-dark); }
.btn-secondary { background: #fff; color: var(--sky); border-color: #C7D7F5; }
.btn-secondary:hover:not(:disabled) { background: #F2F6FE; }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--fog); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #DC2626; }
.btn-sm { height: 38px; padding: 0 14px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }
.btn [data-lucide] { width: 18px; height: 18px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 11.5px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--text-2); margin-bottom: 7px; }
.input, select.input, textarea.input {
  width: 100%; height: 46px; padding: 0 15px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14.5px; font-family: inherit; color: var(--text-1);
  background: #F7F9FC; transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea.input { height: auto; padding: 11px 15px; resize: vertical; }
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--sky); background: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,.13); }
.input-icon { position: relative; }
.input-icon [data-lucide] { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-3); pointer-events: none; }
.input-icon .input { padding-left: 42px; }

.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); }
.card-tight { padding: 16px; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 4px 11px; border-radius: 999px; }
.badge-green { background: var(--green-bg); color: var(--green-text); }
.badge-amber { background: var(--amber-bg); color: var(--amber-text); }
.badge-red { background: var(--red-bg); color: var(--red-text); }
.badge-blue { background: #DBEAFE; color: #1D4ED8; }
.badge-gray { background: #EEF1F7; color: var(--text-2); }

/* ===== Auth (login / registro) ===== */
.auth { display: flex; min-height: 100vh; }
.auth-brand {
  flex: 0 0 46%; position: relative; overflow: hidden;
  background: radial-gradient(120% 90% at 80% 0%, #1A3B5C 0%, var(--blue-deep) 45%, var(--blue-deep-2) 100%);
  color: #fff; padding: 52px 52px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-brand::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 360px; height: 360px; border-radius: 50%; background: radial-gradient(circle, rgba(37,99,235,.22), transparent 70%); pointer-events: none; }
.auth-form-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--fog); }
.auth-form { width: 100%; max-width: 392px; }
.auth-form .card-login { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 18px 50px rgba(16,30,54,.10); padding: 34px 32px; }

.brand-logo { display: flex; align-items: center; gap: 11px; position: relative; z-index: 1; }
.brand-mark { display: flex; align-items: center; justify-content: center; }
.brand-name { font-family: var(--display); font-size: 22px; font-weight: 600; letter-spacing: 2.5px; color: #fff; }
.brand-name b { color: var(--cyan-light); font-weight: 600; }

.auth-hero { position: relative; z-index: 1; max-width: 420px; margin-top: auto; margin-bottom: auto; }
.auth-hero h2 { font-family: var(--display); font-size: 34px; line-height: 1.18; font-weight: 700; letter-spacing: -.5px; }
.auth-hero p { color: #9DB4CC; font-size: 14.5px; margin-top: 16px; line-height: 1.6; }
.auth-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 30px; max-width: 380px; }
.stat-card { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius); padding: 16px 18px; backdrop-filter: blur(4px); }
.stat-card .v { font-family: var(--display); font-size: 24px; font-weight: 700; color: #fff; letter-spacing: -.5px; }
.stat-card .l { font-size: 12.5px; color: #9DB4CC; margin-top: 3px; }
.auth-foot { position: relative; z-index: 1; font-size: 12px; color: #64789A; border-top: 1px solid rgba(255,255,255,.08); padding-top: 16px; }

.compliance { display: flex; align-items: flex-start; gap: 8px; font-size: 11.5px; color: var(--text-3); line-height: 1.5; border-top: 1px solid var(--border-soft); padding-top: 14px; margin-top: 22px; }
.forgot { display: block; text-align: center; font-size: 13px; margin-top: 14px; cursor: pointer; }
.auth-locked { display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 11.5px; color: var(--text-3); margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-soft); }

/* ===== Shell ===== */
.shell { display: flex; min-height: 100vh; }
.sidebar { flex: 0 0 var(--sidebar-w); background: var(--blue-deep); color: #fff; display: flex; flex-direction: column; padding: 22px 16px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand-logo { padding: 4px 8px 26px; }
.sidebar .brand-name { font-size: 20px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: var(--radius); color: #8C9BB4; font-size: 14.5px; font-weight: 500; cursor: pointer; transition: background .15s, color .15s; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--sky); color: #fff; box-shadow: 0 6px 16px rgba(37,99,235,.34); }
.nav-item [data-lucide] { width: 19px; height: 19px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid rgba(255,255,255,.09); margin-top: 8px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--cyan), var(--sky)); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex-shrink: 0; }
.sidebar-user .meta { min-width: 0; }
.sidebar-user .meta .n { font-size: 13.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .meta .r { font-size: 12px; color: #8C9BB4; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 66px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 20px; font-weight: 600; }
.content { padding: 28px; flex: 1; max-width: 1320px; width: 100%; }
.subtitle { color: var(--text-2); font-size: 14px; margin-top: -10px; margin-bottom: 22px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; box-shadow: var(--shadow); }
.kpi .top { display: flex; align-items: center; justify-content: space-between; }
.kpi .ico { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.kpi .ico [data-lucide] { width: 21px; height: 21px; }
.kpi .label { font-size: 13px; color: var(--text-2); margin-top: 16px; }
.kpi .val { font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -1px; margin-top: 2px; }

/* ===== Gráficos dashboard ===== */
.dash-2col { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; margin-bottom: 22px; }
.chart-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 20px 22px; }
.chart-card h3 { font-size: 16px; margin-bottom: 6px; }
.bars { display: flex; align-items: flex-end; justify-content: space-around; gap: 18px; height: 190px; padding: 14px 4px 0; }
.bar-group { display: flex; flex-direction: column; align-items: center; gap: 7px; flex: 1; height: 100%; justify-content: flex-end; }
.bar-pair { display: flex; align-items: flex-end; gap: 6px; height: 100%; }
.bar { width: 16px; border-radius: 5px 5px 0 0; transition: height .5s ease; }
.bar.fx { background: var(--red); }
.bar.nm { background: var(--green); }
.bar-lbl { font-size: 12px; color: var(--text-3); }
.legend { display: flex; gap: 16px; justify-content: center; margin-top: 12px; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.donut-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 0; }
.donut { position: relative; width: 168px; height: 168px; }
.donut .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut .center .pct { font-family: var(--display); font-size: 26px; font-weight: 700; }
.donut .center .cl { font-size: 11.5px; color: var(--text-2); }

.table-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.table-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border-soft); }
table { width: 100%; border-collapse: collapse; }
thead th { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); text-align: left; padding: 13px 22px; background: #F8FAFD; }
tbody td { padding: 14px 22px; font-size: 14px; border-top: 1px solid var(--border-soft); color: var(--text-1); }
tbody tr:hover { background: #F8FBFF; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--text-2); }
.thumb { width: 46px; height: 46px; border-radius: 9px; background: #0A0E14; object-fit: cover; display: block; }

.stepper { display: flex; align-items: center; gap: 0; margin-bottom: 28px; }
.step { display: flex; align-items: center; gap: 10px; }
.step .dot { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; background: #fff; border: 1.5px solid var(--border); color: var(--text-3); }
.step.active .dot { background: var(--sky); border-color: var(--sky); color: #fff; }
.step.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.step .lbl { font-size: 13.5px; font-weight: 500; color: var(--text-3); }
.step.active .lbl, .step.done .lbl { color: var(--text-1); }
.step-line { flex: 1; height: 1.5px; background: var(--border); margin: 0 14px; min-width: 24px; }

.dropzone { border: 2px dashed #C7D2E2; border-radius: var(--radius-lg); padding: 48px 24px; text-align: center; background: #F7F9FC; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--sky); background: #F2F6FE; }
.dropzone .dz-ico { width: 64px; height: 64px; border-radius: 16px; background: #DBEAFE; color: var(--sky); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.dropzone .dz-ico [data-lucide] { width: 30px; height: 30px; }
.fmt-chip { display: inline-block; font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--text-2); background: #EEF1F7; border-radius: 6px; padding: 4px 9px; margin: 0 3px; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab { font-size: 13px; color: var(--text-2); padding: 7px 13px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 500; }
.tab.active { background: var(--sky); color: #fff; }
.scan { border-radius: 12px; overflow: hidden; background: #0A0E14; }
.scan svg { display: block; width: 100%; }

.verdict { border-radius: var(--radius-lg); padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.verdict.pos { background: var(--red-bg); border: 1px solid var(--red-border); }
.verdict.neg { background: #ECFDF5; border: 1px solid #A7F3D0; }
.verdict .vico { width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.verdict.pos .vico { background: var(--red); }
.verdict.neg .vico { background: var(--green); }
.verdict .vico [data-lucide] { color: #fff; width: 23px; height: 23px; }
.verdict .vtitle { font-size: 17px; font-weight: 600; }
.verdict.pos .vtitle { color: var(--red-text); }
.verdict.neg .vtitle { color: var(--green-text); }
.verdict .vsub { font-size: 13px; margin-top: 2px; }
.verdict.pos .vsub { color: var(--red); }
.verdict.neg .vsub { color: #059669; }

.disclaimer { background: var(--fog); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 15px; display: flex; align-items: flex-start; gap: 9px; font-size: 12px; color: var(--text-2); line-height: 1.55; }
.disclaimer [data-lucide] { width: 17px; height: 17px; color: var(--text-3); flex-shrink: 0; margin-top: 1px; }

#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { background: #fff; border: 1px solid var(--border); border-left: 3px solid var(--sky); border-radius: var(--radius); padding: 13px 16px; box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 10px; font-size: 14px; min-width: 260px; animation: slidein .2s ease; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast [data-lucide] { width: 19px; height: 19px; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 80; padding: 20px; }
.modal { background: #fff; border-radius: var(--radius-lg); padding: 26px; max-width: 440px; width: 100%; box-shadow: var(--shadow-md); }
.modal h3 { margin-bottom: 8px; }
.modal p { color: var(--text-2); font-size: 14px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.skeleton { background: linear-gradient(90deg, #EEF2F8 25%, #E3E9F2 50%, #EEF2F8 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.processing { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; text-align: center; }
.proc-steps { display: flex; flex-direction: column; gap: 14px; margin: 28px 0; width: 100%; max-width: 360px; }
.proc-step { display: flex; align-items: center; gap: 12px; font-size: 14.5px; color: var(--text-3); }
.proc-step.active { color: var(--text-1); font-weight: 500; }
.proc-step.done { color: var(--green-text); }
.proc-step .pico { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--border); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.proc-step.active .pico { border-color: var(--sky); }
.proc-step.done .pico { background: var(--green); border-color: var(--green); }
.proc-step.done .pico [data-lucide] { color: #fff; width: 15px; height: 15px; }
.progress { height: 8px; background: #E2E8F0; border-radius: 999px; overflow: hidden; width: 100%; max-width: 360px; }
.progress .bar { height: 100%; background: var(--sky); border-radius: 999px; transition: width .4s ease; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.row { display: flex; gap: 16px; }
.grow { flex: 1; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.empty { text-align: center; padding: 50px 20px; color: var(--text-3); }
.empty [data-lucide] { width: 44px; height: 44px; stroke-width: 1.4; margin-bottom: 12px; }
.hidden { display: none !important; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.filters .field { margin: 0; }
.timeline-item { display: flex; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--border-soft); }
.timeline-thumb { width: 64px; height: 64px; border-radius: var(--radius); background: #0A0E14; flex-shrink: 0; overflow: hidden; }

/* ============ Responsive (tablet / móvil) ============ */
@media (max-width: 1000px) {
  .dash-2col { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    flex: none; width: 100%; height: auto;
    flex-direction: row; align-items: center; gap: 8px;
    padding: 10px 12px; position: sticky; top: 0; z-index: 20;
  }
  .sidebar .brand-logo { padding: 0 6px 0 2px; flex-shrink: 0; }
  .nav { flex-direction: row; flex: 1; min-width: 0; gap: 4px; overflow-x: auto; }
  .nav-item { flex-shrink: 0; padding: 9px 12px; white-space: nowrap; }
  .sidebar-user { border-top: none; margin: 0; padding: 0 2px; flex-shrink: 0; }
  .sidebar-user .meta { display: none; }
  .main { width: 100%; }
}
@media (max-width: 720px) {
  .auth { flex-direction: column; }
  .auth-brand { flex: none; padding: 26px 26px; justify-content: flex-start; gap: 18px; }
  .auth-hero h2 { font-size: 26px; }
  .auth-stats { display: none; }
  .auth-foot { display: none; }
  .auth-form-wrap { padding: 26px 20px; flex: 1; }
  .auth-form .card-login { padding: 26px 22px; box-shadow: none; }

  .row { flex-direction: column; }
  .row > * { flex: 0 0 auto !important; width: 100%; }

  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .page-head { flex-wrap: wrap; gap: 12px; }
  .table-card { overflow-x: auto; }
  .table-head { padding: 14px 16px; }
  thead th, tbody td { padding: 10px 14px; }
  h1 { font-size: 22px; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .step .lbl { display: none; }
  .step-line { margin: 0 8px; min-width: 14px; }
  #toast-container { left: 14px; right: 14px; bottom: 14px; }
  .toast { min-width: 0; }
  .card { padding: 18px; }
}
