:root {
  --navy: #002d62;
  --navy-2: #0a3f80;
  --red: #ce1126;
  --red-soft: #fde8eb;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --green: #047857;
  --green-soft: #d1fae5;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --text: #0f1b2d;
  --muted: #5b6b82;
  --line: #dbe2ee;
  --shadow: 0 1px 2px rgba(15, 27, 45, .06), 0 8px 24px rgba(15, 27, 45, .06);
  --radius: 14px;
  --bubble-in: #ffffff;
  --bubble-out: #dcf8c6;
  --chat-bg: #efe7dd;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #121b2e;
    --surface-2: #1a2540;
    --text: #e8edf6;
    --muted: #9aa8c0;
    --line: #26334f;
    --red-soft: #3b1219;
    --amber-soft: #3a2a0c;
    --amber: #fbbf24;
    --green-soft: #0b3327;
    --green: #34d399;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --bubble-in: #1f2c45;
    --bubble-out: #0f4a3a;
    --chat-bg: #0e1626;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; outline: none; }
a { color: var(--navy-2); }
@media (prefers-color-scheme: dark) { a { color: #8bb8ff; } }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; z-index: 99; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* Barra superior */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; padding: 8px 0; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 1.2rem; letter-spacing: -.01em; }
.brand b { color: #ff6b7d; }
.brand-eye { width: 38px; height: 26px; color: #fff; }
.mainnav { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; }
.mainnav > a:not(.btn), #session a, #session button.linkish { color: #dbe7ff; text-decoration: none; font-weight: 600; font-size: .95rem; padding: 6px 2px; }
.mainnav > a:not(.btn):hover, #session a:hover { color: #fff; text-decoration: underline; }
#session { display: inline-flex; gap: 12px; align-items: center; }
.linkish { background: none; border: 0; cursor: pointer; font: inherit; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px; padding: 11px 18px; font: inherit; font-weight: 700;
  cursor: pointer; text-decoration: none; background: var(--navy); color: #fff; transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-alert { background: var(--red); color: #fff !important; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ok { background: var(--green); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: .9rem; border-radius: 9px; }
.btn-block { width: 100%; }
:focus-visible { outline: 3px solid #ff9db0; outline-offset: 2px; }

/* Héroe y búsqueda */
.hero { background: linear-gradient(160deg, var(--navy) 0%, #08417f 60%, #12305c 100%); color: #fff; padding: 56px 0 72px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -120px; top: -120px; width: 380px; height: 380px; border-radius: 50%; background: radial-gradient(circle, rgba(206,17,38,.35), transparent 70%); }
.hero h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); letter-spacing: -.02em; max-width: 760px; }
.hero h1 em { font-style: normal; color: #ff8a99; }
.hero p.lead { font-size: 1.15rem; color: #cfdcf5; max-width: 680px; }
.searchbox { display: flex; gap: 8px; background: #fff; border-radius: 16px; padding: 8px; box-shadow: 0 12px 40px rgba(0,0,0,.25); max-width: 760px; position: relative; z-index: 1; }
.searchbox input[type=search] { flex: 1; min-width: 0; border: 0; font: inherit; font-size: 1.1rem; padding: 10px 12px; color: #0f1b2d; background: transparent; }
.searchbox input[type=search]:focus { outline: none; border: 0; }
.searchbox .btn { padding-inline: 22px; }
.search-hints { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; position: relative; z-index: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 12px; font-size: .85rem; font-weight: 600; background: rgba(255,255,255,.12); color: #e5eeff; border: 1px solid rgba(255,255,255,.2); }
.searchbar-page { margin: 28px 0 8px; }
.searchbar-page .searchbox { max-width: none; border: 1px solid var(--line); box-shadow: var(--shadow); }

/* Estadísticas */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: -40px; position: relative; z-index: 2; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.stat b { display: block; font-size: 1.7rem; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: .9rem; }

/* Secciones */
.section { padding: 40px 0 8px; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 1.5rem; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1.6fr 1fr; align-items: start; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card h3 { font-size: 1.1rem; }

/* Tarjetas de alerta */
.alert-card { display: block; text-decoration: none; color: inherit; transition: transform .12s, border-color .12s; position: relative; }
.alert-card:hover { transform: translateY(-2px); border-color: #9fb3d6; }
.alert-card .top { display: flex; justify-content: space-between; gap: 10px; align-items: start; margin-bottom: 8px; }
.alert-card h3 { margin: 0 0 6px; }
.alert-card .ids { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: .85rem; }
.amount { font-weight: 800; color: var(--red); }
@media (prefers-color-scheme: dark) { .amount { color: #ff7a8a; } }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 800; border-radius: 999px; padding: 4px 10px; white-space: nowrap; text-transform: uppercase; letter-spacing: .03em; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.risk-1 { background: var(--amber-soft); color: var(--amber); }
.risk-2 { background: #ffe4d1; color: #c2410c; }
.risk-3 { background: var(--red-soft); color: var(--red); }
@media (prefers-color-scheme: dark) { .risk-2 { background: #3d1e0b; color: #fb923c; } .risk-3 { color: #ff7a8a; } }
.badge-pend { background: var(--surface-2); color: var(--muted); }
.badge-ok { background: var(--green-soft); color: var(--green); }
.badge-bad { background: var(--red-soft); color: var(--red); }

.ident { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: .9rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.ident small { color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
button.ident { cursor: pointer; font: inherit; color: inherit; }
button.ident:hover { border-color: var(--navy-2); }

/* Resultados de búsqueda */
.result-empty { text-align: center; padding: 36px 20px; }
.result-empty .big { font-size: 3rem; line-height: 1; margin-bottom: 8px; }
.verdict { border-radius: var(--radius); padding: 18px 20px; margin: 16px 0; display: flex; gap: 14px; align-items: start; border: 1px solid; }
.verdict.warn { background: var(--red-soft); border-color: #f5b5bf; }
.verdict.clear { background: var(--green-soft); border-color: #9be3c6; }
@media (prefers-color-scheme: dark) { .verdict.warn { border-color: #6b1f2b; } .verdict.clear { border-color: #145c45; } }
.verdict .ico { font-size: 1.8rem; line-height: 1; }
.verdict h2 { font-size: 1.2rem; margin-bottom: 4px; }
.verdict p { margin: 0; }

/* Perfil */
.profile-head { display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; }
.avatar { width: 76px; height: 76px; border-radius: 20px; display: grid; place-items: center; font-size: 2rem; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--red), #7a0a18); }
.profile-head h1 { font-size: clamp(1.4rem, 3vw, 2rem); margin: 6px 0; }
.kpis { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 6px; }
.kpis div b { display: block; font-size: 1.25rem; }
.kpis div span { color: var(--muted); font-size: .82rem; }
.banner { border-radius: 12px; padding: 12px 16px; margin: 16px 0; font-size: .95rem; }
.banner-info { background: var(--surface-2); border: 1px solid var(--line); }
.banner-warn { background: var(--amber-soft); border: 1px solid #f3d27a; }
@media (prefers-color-scheme: dark) { .banner-warn { border-color: #6b5313; } }
.reply { border-left: 4px solid var(--navy-2); background: var(--surface-2); padding: 12px 16px; border-radius: 0 10px 10px 0; margin-bottom: 10px; }

.report { padding: 22px; }
.report + .report { margin-top: 16px; }
.report-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.report h3 { font-size: 1.15rem; margin: 0; }
.narrative { white-space: pre-wrap; overflow-wrap: anywhere; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 12px 0; }
.gallery button { padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: zoom-in; background: var(--surface-2); aspect-ratio: 3 / 4; }
.gallery img { width: 100%; height: 100%; object-fit: cover; }
.lightbox { position: fixed; inset: 0; background: rgba(3, 8, 18, .92); display: grid; place-items: center; z-index: 100; padding: 20px; }
.lightbox img { max-height: 86vh; max-width: 100%; border-radius: 8px; }
.lightbox figcaption { color: #dbe4f3; text-align: center; margin-top: 10px; }
.lightbox .close { position: absolute; top: 14px; right: 14px; }

/* Chat */
.chat { background: var(--chat-bg); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 6px; max-height: 460px; overflow: auto; margin: 12px 0; border: 1px solid var(--line); }
.bubble { max-width: 78%; padding: 7px 11px 5px; border-radius: 10px; background: var(--bubble-in); box-shadow: 0 1px 1px rgba(0,0,0,.08); align-self: flex-start; overflow-wrap: anywhere; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); }
.bubble .who { display: block; font-size: .75rem; font-weight: 800; color: var(--red); }
.bubble.out .who { color: var(--green); }
.bubble time { display: block; text-align: right; font-size: .68rem; color: var(--muted); margin-top: 2px; }
.chat-raw { white-space: pre-wrap; font-size: .9rem; }

/* Comentarios */
.comment { padding: 12px 0; border-top: 1px solid var(--line); }
.comment:first-child { border-top: 0; }
.comment .who { font-weight: 700; font-size: .9rem; }
.comment p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Formularios */
.form-page { max-width: 820px; margin: 32px auto; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 700; margin-bottom: 6px; font-size: .95rem; }
.field > small { display: block; color: var(--muted); margin-top: 4px; font-size: .82rem; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
textarea { min-height: 130px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy-2); outline-offset: 0; border-color: var(--navy-2); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { grid-template-columns: 1fr 1fr 1fr; }
.check { display: flex; gap: 10px; align-items: start; margin: 12px 0; }
.check input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.error { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 10px 14px; margin: 12px 0; font-weight: 600; }
@media (prefers-color-scheme: dark) { .error { color: #ffb3bd; } }

.steps { display: flex; gap: 6px; margin-bottom: 20px; counter-reset: s; }
.steps li { flex: 1; list-style: none; font-size: .82rem; font-weight: 700; color: var(--muted); border-top: 4px solid var(--line); padding-top: 8px; }
.steps li.on { color: var(--navy-2); border-color: var(--navy-2); }
.steps li.done { color: var(--green); border-color: var(--green); }
@media (prefers-color-scheme: dark) { .steps li.on { color: #8bb8ff; border-color: #8bb8ff; } }
.steps { padding: 0; }
.step-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.ident-row { display: grid; grid-template-columns: 170px 1fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.ident-row.with-bank { grid-template-columns: 170px 150px 1fr auto; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 9px; width: 40px; height: 40px; cursor: pointer; font-size: 1.1rem; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.thumb { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 150px; object-fit: cover; }
.thumb .tools { display: flex; gap: 4px; padding: 6px; }
.thumb input { font-size: .8rem; padding: 6px 8px; }
.dropzone { display: block; border: 2px dashed var(--line); border-radius: 14px; padding: 26px; text-align: center; cursor: pointer; background: var(--surface-2); }
.dropzone:hover, .dropzone.drag { border-color: var(--navy-2); }
.review-list dt { font-weight: 700; margin-top: 10px; }
.review-list dd { margin: 2px 0 0; color: var(--muted); overflow-wrap: anywhere; }

/* Editor para tapar datos */
.editor { position: fixed; inset: 0; z-index: 100; background: rgba(3, 8, 18, .94); display: flex; flex-direction: column; padding: 14px; gap: 10px; }
.editor-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: #e3ebf8; }
.editor-bar .spacer { flex: 1; }
.editor-stage { flex: 1; min-height: 0; display: grid; place-items: center; overflow: auto; }
.editor canvas { max-width: 100%; max-height: 100%; touch-action: none; cursor: crosshair; border-radius: 6px; background: #000; }

/* Pestañas y moderación */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; }
.tabs button.on { color: var(--text); border-color: var(--red); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters button { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; }
.filters button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.mod-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.mod-actions input { flex: 1; min-width: 200px; }

.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: .9rem; }
.bar i { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i::after { content: ""; display: block; height: 100%; width: var(--w); background: linear-gradient(90deg, var(--red), #ff6b7d); border-radius: 99px; }

.tips { counter-reset: t; display: grid; gap: 12px; padding: 0; margin: 0; }
.tips li { list-style: none; display: grid; grid-template-columns: 34px 1fr; gap: 10px; }
.tips li::before { counter-increment: t; content: counter(t); width: 30px; height: 30px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .9rem; }
.prose { max-width: 780px; }
.prose h2 { margin-top: 1.6em; }
.prose li { margin-bottom: .4em; }

.footer { background: #071a36; color: #b8c6de; margin-top: 56px; padding: 32px 0; font-size: .92rem; }
.footer-in { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.footer-in > div { max-width: 620px; }
.footer strong { color: #fff; }
.footer nav { display: flex; flex-direction: column; gap: 6px; }
.footer a { color: #dbe7ff; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(140%); background: #0f1b2d; color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.3); transition: transform .25s; z-index: 200; max-width: calc(100% - 32px); }
#toast.show { transform: translateX(-50%) translateY(0); }
.skeleton { height: 140px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .profile-head { grid-template-columns: auto 1fr; }
  .profile-head > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .mainnav { width: 100%; justify-content: space-between; }
  .mainnav > a[href="#/guia"] { display: none; }
  .hero { padding: 36px 0 64px; }
  .searchbox { flex-direction: column; }
  .row, .row-3 { grid-template-columns: 1fr; }
  .ident-row, .ident-row.with-bank { grid-template-columns: 1fr auto; }
  .ident-row > select { grid-column: 1 / -1; }
  .ident-row { padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
  .bubble { max-width: 90%; }
  .avatar { width: 56px; height: 56px; font-size: 1.5rem; border-radius: 16px; }
}
