/* ================================================================
   Diagnóstika Riesgos Gudiño© · styles.css  (v9.5)
   ================================================================ */

:root {
  --bg: #f4f6fb; --surface: #ffffff; --surface-2: #f8fafc; --text: #0f172a;
  --muted: #64748b; --border: #e2e8f0; --primary: #1e3a8a; --primary-hover: #172554;
  --red: #dc2626; --red-hover: #b91c1c; --green: #16a34a; --green-hover: #15803d;
  --amber: #f59e0b; --amber-hover: #d97706; --slate: #475569; --slate-hover: #334155;
  --blue: #2563eb; --blue-hover: #1d4ed8;
  --shadow: 0 4px 24px rgba(15, 23, 42, .08); --shadow-lg: 0 12px 40px rgba(15, 23, 42, .12);
  --radius: 14px; --radius-sm: 10px;
}

[data-theme="dark"] {
  --bg: #0b1220; --surface: #131c2e; --surface-2: #0f1828; --text: #e2e8f0;
  --muted: #94a3b8; --border: #22304a; --primary: #3b82f6; --primary-hover: #60a5fa;
  --red: #ef4444; --red-hover: #f87171; --green: #22c55e; --green-hover: #4ade80;
  --amber: #fbbf24; --amber-hover: #fcd34d; --slate: #94a3b8; --slate-hover: #cbd5e1;
  --blue: #60a5fa; --blue-hover: #93c5fd;
  --shadow: 0 4px 24px rgba(0, 0, 0, .5); --shadow-lg: 0 12px 40px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
  transition: background .3s ease, color .3s ease; min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: .85em; }

/* LOGIN OVERLAY */
.login-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.login-overlay.hidden { display: none !important; }
.login-box { background: var(--surface); padding: 30px; border-radius: var(--radius); width: 100%; max-width: 380px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.login-header { text-align: center; margin-bottom: 25px; }
.login-header .logo-slot { margin: 0 auto 15px; cursor: default; }
.login-header h2 { font-size: 1.2rem; color: var(--primary); }
.login-header p { font-size: 0.85rem; color: var(--muted); }
.login-error { color: var(--red); font-size: 0.85rem; text-align: center; margin-top: 10px; }

/* TOPBAR */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); position: sticky; top: 0; z-index: 100; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo-slot { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg, var(--red), var(--amber)); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.15rem; cursor: pointer; overflow: hidden; box-shadow: 0 4px 12px rgba(220, 38, 38, .3); transition: transform .15s ease; flex-shrink: 0; }
.logo-slot:hover { transform: scale(1.05); }
.logo-slot img { width: 100%; height: 100%; object-fit: cover; }
.logo-fallback { pointer-events: none; letter-spacing: -.5px; }
.brand-text h1 { font-size: 1.1rem; font-weight: 800; letter-spacing: -.3px; color: var(--text); }
.brand-text .subtitle { font-size: .76rem; color: var(--muted); margin-top: 2px; }
.topnav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-btn { padding: 9px 16px; border: 1px solid transparent; background: transparent; color: var(--muted); border-radius: var(--radius-sm); cursor: pointer; font-size: .88rem; font-weight: 600; transition: all .2s ease; }
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(30, 58, 138, .3); }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn { width: 42px; height: 42px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 12px; cursor: pointer; font-size: 1.1rem; transition: all .2s ease; }
.icon-btn:hover { transform: translateY(-2px); border-color: var(--primary); }
.hidden { display: none !important; }

.app-main { padding: 28px; max-width: 1400px; margin: 0 auto; }
.view { display: none; animation: fadeIn .35s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.bento { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.hero-card { grid-column: span 2; grid-row: span 2; background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%); position: relative; overflow: hidden; }
.hero-card::before { content: ''; position: absolute; top: -50%; right: -30%; width: 300px; height: 300px; background: radial-gradient(circle, rgba(220, 38, 38, .08), transparent 70%); pointer-events: none; }
.stat-card { grid-column: span 1; }
.action-card { grid-column: span 2; }
@media (max-width: 900px) { .bento { grid-template-columns: repeat(2, 1fr); } .hero-card, .action-card { grid-column: span 2; } }
@media (max-width: 560px) { .bento { grid-template-columns: 1fr; } .hero-card, .action-card { grid-column: span 1; } .topbar { padding: 12px 16px; } .app-main { padding: 16px; } }

.bento-card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.bento-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.hero-card h2 { font-size: 1.5rem; margin: 12px 0 10px; letter-spacing: -.5px; }
.hero-card p { color: var(--muted); margin-bottom: 20px; line-height: 1.6; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-card { display: flex; flex-direction: column; justify-content: space-between; min-height: 120px; }
.stat-label { color: var(--muted); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 2.4rem; font-weight: 800; color: var(--primary); letter-spacing: -1px; }
.recent-card { justify-content: flex-start; gap: 4px; }
.recent-code { font-family: 'Courier New', monospace; font-size: 1.05rem; font-weight: 700; color: var(--red); letter-spacing: .5px; margin-top: 8px; word-break: break-all; }
.recent-date { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.action-card h3 { margin-bottom: 16px; }
.action-grid { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { display: inline-block; padding: 5px 12px; border-radius: 20px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; }
.chip-red { background: rgba(220, 38, 38, .12); color: var(--red); }
.chip-green { background: rgba(22, 163, 74, .12); color: var(--green); }
.chip-amber { background: rgba(245, 158, 11, .15); color: var(--amber); }

.btn { padding: 11px 20px; border: none; border-radius: var(--radius-sm); font-weight: 700; font-size: .9rem; cursor: pointer; transition: all .2s ease; color: #fff; letter-spacing: .2px; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); } .btn-primary:hover { background: var(--primary-hover); }
.btn-red { background: var(--red); } .btn-red:hover { background: var(--red-hover); }
.btn-green { background: var(--green); } .btn-green:hover { background: var(--green-hover); }
.btn-amber { background: var(--amber); color: #1a1a1a; } .btn-amber:hover { background: var(--amber-hover); }
.btn-blue { background: var(--blue); } .btn-blue:hover { background: var(--blue-hover); }
.btn-slate { background: var(--slate); } .btn-slate:hover { background: var(--slate-hover); }

.wizard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.wizard-steps { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.step { flex: 1; min-width: 160px; padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--muted); font-weight: 600; font-size: .85rem; display: flex; align-items: center; gap: 10px; transition: all .25s ease; }
.step span { width: 26px; height: 26px; border-radius: 50%; background: var(--border); color: var(--text); display: grid; place-items: center; font-size: .8rem; font-weight: 800; flex-shrink: 0; }
.step.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 4px 12px rgba(30, 58, 138, .25); }
.step.active span { background: #fff; color: var(--primary); }
.step.done { background: rgba(22, 163, 74, .12); border-color: var(--green); color: var(--green); }
.step.done span { background: var(--green); color: #fff; }
.wizard-panel { display: none; border: none; padding: 0; }
.wizard-panel.active { display: block; animation: fadeIn .3s ease; }
.wizard-panel legend { font-size: 1.15rem; font-weight: 800; margin-bottom: 20px; padding: 0; }
label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 16px; }
input[type="text"], input[type="number"], input[type="date"], input[type="tel"], input[type="email"], input[type="password"], select, textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font-size: .92rem; font-family: inherit; transition: border-color .2s ease, box-shadow .2s ease; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30, 58, 138, .12); }
input[readonly] { background: #e2e8f0; color: #64748b; cursor: not-allowed; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 20px; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }
.check-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
@media (max-width: 700px) { .check-grid { grid-template-columns: 1fr; } }
.check-label { flex-direction: row !important; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; color: var(--text); font-weight: 500; margin: 0; transition: all .2s ease; }
.check-label:hover { border-color: var(--primary); }
.check-label input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--red); cursor: pointer; }
.floors-box { margin-top: 20px; padding: 18px; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px dashed var(--border); }
.floors-box h4 { margin-bottom: 12px; font-size: .95rem; color: var(--primary); }
.floors-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.wizard-actions { display: flex; gap: 12px; margin-top: 28px; justify-content: flex-end; flex-wrap: wrap; }

.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.panel-header h2 { font-size: 1.35rem; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.history-search { margin-bottom: 18px; }
.history-search input { width: 100%; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font-size: .92rem; font-family: inherit; transition: border-color .2s ease, box-shadow .2s ease; }
.history-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30, 58, 138, .12); }
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 18px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); flex-wrap: wrap; transition: border-color .2s ease; }
.history-item:hover { border-color: var(--primary); }
.history-info h4 { font-size: 1rem; margin-bottom: 4px; }
.history-info p { font-size: .82rem; color: var(--muted); }
.history-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.history-actions .btn { padding: 8px 14px; font-size: .82rem; }
.history-checkbox { width: 20px; height: 20px; accent-color: var(--red); cursor: pointer; }

.report-toolbar { display: flex; gap: 12px; justify-content: flex-end; margin-bottom: 18px; flex-wrap: wrap; }
.report-paper { background: #ffffff; color: #0f172a; max-width: 900px; margin: 0 auto; padding: 56px 56px 72px; box-shadow: var(--shadow-lg); border-radius: var(--radius); font-size: .9rem; line-height: 1.55; }
.rp-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid #1e3a8a; padding-bottom: 20px; margin-bottom: 24px; gap: 20px; flex-wrap: wrap; }
.rp-header-left { display: flex; align-items: center; gap: 16px; }
.rp-logo { width: 62px; height: 62px; border-radius: 12px; background: linear-gradient(135deg, #dc2626, #f59e0b); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1.3rem; overflow: hidden; flex-shrink: 0; }
.rp-logo img { width: 100%; height: 100%; object-fit: cover; }
.rp-title { font-size: 1.08rem; font-weight: 800; color: #1e3a8a; letter-spacing: -.3px; line-height: 1.35; max-width: 480px; }
.rp-subtitle { font-size: .78rem; color: #64748b; margin-top: 4px; }
.rp-meta { text-align: right; font-size: .8rem; color: #475569; }
.rp-meta strong { color: #1e3a8a; }
.rp-section { margin-bottom: 26px; page-break-inside: avoid; }
.rp-section h3 { font-size: 1rem; color: #1e3a8a; border-left: 4px solid #dc2626; padding-left: 10px; margin-bottom: 12px; text-transform: uppercase; letter-spacing: .5px; }
.rp-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 24px; font-size: .85rem; }
.rp-grid div { padding: 4px 0; border-bottom: 1px dotted #e2e8f0; }
.rp-grid strong { color: #1e3a8a; }
.rp-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: .82rem; }
.rp-table th, .rp-table td { border: 1px solid #cbd5e1; padding: 8px 10px; text-align: left; }
.rp-table th { background: #1e3a8a; color: #fff; font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; }
.rp-table tbody tr:nth-child(even) { background: #f8fafc; }
.rp-list { list-style: none; padding: 0; }
.rp-list li { padding: 5px 0 5px 22px; position: relative; font-size: .85rem; }
.rp-list li::before { content: '✓'; position: absolute; left: 0; color: #16a34a; font-weight: 800; }
.rp-alert { background: #fef3c7; border-left: 4px solid #f59e0b; padding: 12px 16px; border-radius: 6px; font-size: .85rem; color: #78350f; margin: 12px 0; }
.rp-section-intro { font-size: .82rem; color: #475569; font-style: italic; margin-bottom: 12px; line-height: 1.55; }
.rp-table-evac th, .rp-table-evac td { vertical-align: top; }
.rp-table-evac th:nth-child(1), .rp-table-evac td:nth-child(1) { width: 22%; }
.rp-table-evac th:nth-child(2), .rp-table-evac td:nth-child(2) { width: 24%; }
.rp-table-evac th:nth-child(3), .rp-table-evac td:nth-child(3) { width: 54%; }
.rp-table-evac tbody tr:nth-child(even) { background: #f8fafc; }
.rp-table-evac .rp-state { font-weight: 600; font-size: .82rem; line-height: 1.35; color: #0f172a; }
.rp-table-evac td:nth-child(1) strong { color: #1e3a8a; font-size: .82rem; }
.rp-evac-legend { margin-top: 12px; font-size: .74rem; color: #334155; background: #f8fafc; border-left: 3px solid #1e3a8a; padding: 10px 14px; border-radius: 4px; line-height: 1.55; }
.rp-evac-legend strong { color: #1e3a8a; }

.rp-signature { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 56px; padding-top: 24px; }
.rp-sign-box { text-align: center; font-size: .8rem; }
.rp-sign-line { border-top: 1px solid #0f172a; margin-top: 56px; padding-top: 8px; line-height: 1.55; color: #334155; position: relative; }
.rp-sign-line img { max-height: 60px; margin: 0 auto; display: block; position: absolute; top: -65px; left: 0; right: 0; }
.rp-sign-box strong { display: block; color: #1e3a8a; margin-bottom: 2px; }
.rp-sign-cargo { white-space: nowrap; font-size: 0.72rem; letter-spacing: -0.2px; }

.rp-disclaimer { background: #f1f5f9; border: 1px solid #cbd5e1; border-left: 4px solid #1e3a8a; padding: 18px 20px; border-radius: 6px; margin-top: 32px; page-break-inside: avoid; }
.rp-disclaimer h3 { border-left: none !important; padding-left: 0 !important; color: #1e3a8a; font-size: .95rem; margin-bottom: 10px; }
.rp-disclaimer p { font-size: .76rem; line-height: 1.65; color: #334155; text-align: justify; }
.rp-footer { margin-top: 28px; padding-top: 12px; border-top: 1px solid #cbd5e1; font-size: .72rem; color: #64748b; text-align: center; line-height: 1.55; }
.rp-footer-contact { margin-top: 6px; padding-top: 6px; border-top: 1px dashed #cbd5e1; color: #1e3a8a; font-weight: 700; font-size: .74rem; }
.rp-footer-contact .brand-line { color: #dc2626; font-weight: 800; letter-spacing: .3px; }
.muted { color: var(--muted); } .small { font-size: .8rem; } .center { text-align: center; }

.toast { position: fixed; bottom: 24px; right: 24px; background: var(--primary); color: #fff; padding: 14px 22px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 600; font-size: .9rem; opacity: 0; transform: translateY(20px); transition: all .3s ease; pointer-events: none; z-index: 999; max-width: 340px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; color: #000 !important; font-size: 11pt; }
  .topbar, .no-print, .toast, .wizard-actions, .wizard-steps, .report-toolbar, .topnav, .topbar-actions, .history-search, .login-overlay { display: none !important; }
  .app-main { padding: 0 !important; max-width: 100% !important; }
  .view { display: none !important; }
  #view-report { display: block !important; }
  .report-paper { box-shadow: none !important; border-radius: 0 !important; padding: 0 !important; max-width: 100% !important; margin: 0 !important; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .rp-section, .rp-signature, .rp-disclaimer { page-break-inside: avoid; }
  .rp-table-evac { page-break-inside: avoid; }
}