/* SIC Auditoría · estilos */
:root {
  --navy: #12385d; --navy-2: #0c2843; --navy-3: #1d4f7f; --celeste: #e8eff6;
  --verde: #0a8f3c; --rojo: #d21f1f; --ambar: #b86e00; --gris: #6b7785;
  --bg: #f3f5f8; --card: #fff; --texto: #1d2733; --borde: #dce2e9;
  --radio: 10px; --sombra: 0 1px 3px rgba(18, 56, 93, .08), 0 4px 14px rgba(18, 56, 93, .06);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--texto); background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { font-size: 15px; line-height: 1.45; }
a { color: var(--navy-3); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { color: var(--navy); margin: 0 0 .5em; line-height: 1.2; }
.oculto { display: none !important; }

/* ---------- estructura */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.lateral { background: var(--navy); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.lateral .marca { padding: 18px 18px 10px; }
.lateral .marca img { width: 150px; display: block; }
.lateral .marca small { display: block; opacity: .75; margin-top: 6px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.lateral nav { display: flex; flex-direction: column; padding: 8px; gap: 2px; flex: 1; }
.lateral nav a { color: #dbe6f2; text-decoration: none; padding: 10px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center; }
.lateral nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.lateral nav a.activo { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.lateral nav svg { width: 18px; height: 18px; flex: none; }
.lateral .pie { padding: 14px 18px; font-size: 13px; border-top: 1px solid rgba(255,255,255,.12); }
.lateral .pie button { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; padding: 0; }
.principal { min-width: 0; }
.barra { display: none; }
.contenido { padding: 24px 28px 60px; max-width: 1280px; }
.titulo { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.titulo h1 { font-size: 24px; margin: 0; flex: 1; min-width: 200px; }
.titulo .acciones { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- componentes */
.card { background: var(--card); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); padding: 18px; margin-bottom: 16px; }
.card h2 { font-size: 17px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { background: var(--card); border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px 16px; box-shadow: var(--sombra); }
.kpi span { display: block; color: var(--gris); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi b { display: block; font-size: 21px; color: var(--navy); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--gris); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--borde); background: #fff; color: var(--navy); padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: var(--navy-3); }
.btn.pri { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.pri:hover { background: var(--navy-3); }
.btn.peligro { color: var(--rojo); }
.btn.chico { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--gris); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--borde); background: #fafbfc; }
.tabla td { padding: 8px 10px; border-bottom: 1px solid var(--borde); vertical-align: middle; }
.tabla tr:hover td { background: #f8fafc; }
.tabla .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabla tfoot td { font-weight: 700; border-top: 2px solid var(--borde); }
.tabla-wrap { overflow-x: auto; }
.pos { color: var(--verde); } .neg { color: var(--rojo); }
.muted { color: var(--gris); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--celeste); color: var(--navy); }
.tag.final { background: #dff3e6; color: var(--verde); }
.tag.excel { background: #e3f1e8; color: #17643a; }
label.campo { display: block; margin-bottom: 12px; }
label.campo > span { display: block; font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=month], input[type=email], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--borde); border-radius: 8px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(29, 79, 127, .25); border-color: var(--navy-3); }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
.fila { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.fila > * { flex: 1; min-width: 160px; }
.vacio { text-align: center; padding: 40px 20px; color: var(--gris); }
.vacio svg { width: 48px; height: 48px; opacity: .4; }
.aviso { background: #fff7e6; border: 1px solid #f3d9a4; color: #7a4d00; padding: 10px 12px; border-radius: 8px; margin: 8px 0; font-size: 14px; }
.ok-box { background: #e9f7ee; border: 1px solid #b9e2c7; color: #17643a; padding: 10px 12px; border-radius: 8px; margin: 8px 0; }
.drop { display: block; border: 2px dashed #b9c6d4; border-radius: 12px; padding: 40px 20px; text-align: center; background: #fbfcfe; cursor: pointer; transition: .15s; }
.drop:hover, .drop.sobre { border-color: var(--navy-3); background: var(--celeste); }
.drop svg { width: 44px; height: 44px; color: var(--navy-3); }
.drop b { display: block; color: var(--navy); font-size: 17px; margin: 8px 0 4px; }
.lista-clientes { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.cli { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; box-shadow: var(--sombra); text-decoration: none; color: inherit; display: block; transition: .15s; }
.cli:hover { border-color: var(--navy-3); transform: translateY(-1px); }
.cli h3 { margin: 0 0 4px; font-size: 16px; }
.cli .met { display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; }
.cli .met b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---------- modal y avisos */
.modal-fondo { position: fixed; inset: 0; background: rgba(12, 40, 67, .45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--borde); display: flex; align-items: center; }
.modal header h2 { margin: 0; flex: 1; font-size: 18px; }
.modal .cuerpo { padding: 18px 20px; }
.modal footer { padding: 12px 20px; border-top: 1px solid var(--borde); display: flex; justify-content: flex-end; gap: 8px; }
.x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--gris); line-height: 1; }
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--navy-2); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--sombra); max-width: 360px; animation: entra .2s; }
.toast.error { background: var(--rojo); }
@keyframes entra { from { opacity: 0; transform: translateY(6px); } }

/* ---------- ingreso */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%); }
.login form { background: #fff; border-radius: 14px; padding: 30px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login img { width: 210px; display: block; margin: 0 auto 6px; }
.login p { text-align: center; color: var(--gris); margin: 0 0 20px; }
.login .btn { width: 100%; justify-content: center; padding: 11px; }
.login .err { color: var(--rojo); font-size: 14px; min-height: 20px; text-align: center; }

/* ---------- editor de informe */
.editor-barra { position: sticky; top: 0; z-index: 20; background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); padding: 8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 14px; }
.editor-barra .sep { width: 1px; height: 26px; background: var(--borde); margin: 0 4px; }
.editor-barra button { border: 1px solid transparent; background: none; border-radius: 6px; padding: 5px 8px; cursor: pointer; color: var(--navy); font-weight: 600; min-width: 32px; display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.editor-barra button:hover { background: var(--celeste); }
.editor-barra button svg { width: 16px; height: 16px; }
.editor-barra .estado { margin-left: auto; font-size: 13px; color: var(--gris); padding: 0 6px; }
.editor-barra .c-verde { color: var(--verde); } .editor-barra .c-rojo { color: var(--rojo); }
.hoja-wrap { overflow-x: auto; padding-bottom: 30px; }
.hoja { background: #fff; width: 210mm; max-width: 100%; margin: 0 auto; box-shadow: 0 2px 14px rgba(0,0,0,.12); padding: 18mm 17mm 20mm; min-height: 297mm; }
.doc { outline: none; }
.doc:focus { outline: none; }

/* ---------- informe (pantalla e impresión) */
.doc { font-family: "Times New Roman", Times, Georgia, serif; font-size: 11.5pt; line-height: 1.42; color: #111; }
.doc .doc-head { text-align: left; margin-bottom: 6mm; border-bottom: 2px solid var(--navy); padding-bottom: 3mm; }
.doc .doc-head img { height: 22mm; }
.doc h1 { font-size: 17pt; color: var(--navy); margin: 0 0 2mm; letter-spacing: .01em; }
.doc .sub { color: #333; margin: 0 0 5mm; font-size: 11pt; }
.doc h2 { font-size: 13pt; color: var(--navy); font-style: italic; text-decoration: underline; margin: 7mm 0 3mm; break-after: avoid; }
.doc h3 { font-size: 11.5pt; color: var(--navy); margin: 4mm 0 1.5mm; break-after: avoid; }
.doc p { margin: 0 0 2.5mm; text-align: justify; }
.doc p.det { font-size: 10pt; color: #444; }
.doc p.nota { font-size: 9.5pt; color: #555; }
.doc .pos { color: #00a046; } .doc .neg { color: #e00000; }
.doc table.tbl { width: 100%; border-collapse: collapse; margin: 2mm 0 4mm; font-size: 10.5pt; break-inside: auto; }
.doc table.tbl-sm { font-size: 8.8pt; }
.doc .tbl-sm th, .doc .tbl-sm td { padding: 1.2mm 1.3mm; }
.doc .tbl th { background: var(--navy); color: #fff; padding: 1.6mm 2mm; text-align: left; border: 1px solid var(--navy); font-weight: 700; }
.doc .tbl td { padding: 1.4mm 2mm; border: 1px solid #c9d2dc; vertical-align: top; }
.doc .tbl tr { break-inside: avoid; }
.doc .tbl tbody tr:nth-child(even) td { background: #f4f7fa; }
.doc .tbl td.num { text-align: right; white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
.doc .tbl tr.tot td { background: var(--celeste) !important; font-weight: 700; }
.doc .chip { display: inline-block; padding: 0 1.4mm; border-radius: 2mm; font-size: 7.5pt; font-weight: 700; font-family: "Segoe UI", Arial, sans-serif; vertical-align: middle; white-space: nowrap; }
.doc .chip-urg { color: #fff; background: #e00000; }
.doc .chip-sobre { color: #7a4d00; background: #ffe2a8; }
.doc .chip-ok { color: #0b6b33; background: #d6f2df; }
.doc .chip-bajo { color: #1d4f7f; background: #dfeaf6; }
.doc .chip-sin { color: #555; background: #eceff2; }
.doc .firma { margin-top: 10mm; text-align: left; color: var(--navy); line-height: 1.5; }
.doc figure.chart { margin: 3mm 0 5mm; padding: 3mm 4mm; border: 1px solid #dce2e9; border-radius: 2mm; break-inside: avoid; font-family: "Segoe UI", Arial, sans-serif; font-size: 8.5pt; user-select: none; }
.doc figure.chart figcaption { font-weight: 700; color: var(--navy); margin-bottom: 2mm; font-size: 9pt; }
.doc .hb { display: grid; grid-template-columns: 40mm 1fr 28mm; gap: 2mm; align-items: center; margin: 1mm 0; }
.doc .hb-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc .hb-t { position: relative; height: 4.2mm; background: #f3f5f8; border-radius: 1mm; }
.doc .hb-t i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 1mm; }
.doc .hb-ref { background: rgba(80, 90, 100, .2); top: -1mm !important; bottom: -1mm !important; }
.doc .hb-b { background: var(--navy-3); }
.doc .hb-b.hb-urg { background: #e00000; } .doc .hb-b.hb-sobre { background: #e9a23b; } .doc .hb-b.hb-ok { background: #1f9d55; } .doc .hb-b.hb-bajo { background: #6f9fd0; }
.doc .hb-p { height: 1.1mm; top: auto !important; bottom: -1.6mm !important; background: #333; opacity: .55; }
.doc .hb-v { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc .vb { display: flex; gap: 4mm; align-items: flex-end; height: 38mm; padding: 0 2mm; border-bottom: 1px solid #c9d2dc; }
.doc .vb-g { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; max-width: 22mm; }
.doc .vb-bars { flex: 1; width: 100%; display: flex; gap: 1mm; align-items: flex-end; }
.doc .vb-bars i { flex: 1; display: block; border-radius: 1mm 1mm 0 0; min-height: 1px; }
.doc .vb-i, .doc .legend .vb-i { background: var(--navy); } .doc .vb-e, .doc .legend .vb-e { background: #9fb4ca; }
.doc .vb-l { margin-top: 1mm; white-space: nowrap; }
.doc .vb-r { font-weight: 700; }
.doc .legend { display: flex; gap: 5mm; margin-top: 3mm; color: #555; }
.doc .legend i { display: inline-block; width: 3mm; height: 3mm; margin-right: 1mm; vertical-align: middle; }
.doc ul, .doc ol { margin: 0 0 2.5mm 6mm; padding: 0; }
.doc [contenteditable=false] { cursor: default; }
.doc .salto { break-after: page; height: 0; border-top: 1px dashed #b9c6d4; margin: 6mm 0; position: relative; }
.doc .salto::after { content: "salto de página"; position: absolute; right: 0; top: -9px; font-size: 10px; background: #fff; color: #8899aa; padding: 0 4px; font-family: Arial, sans-serif; }

/* ---------- impresión: solo la hoja del informe */
@page { size: A4; margin: 14mm 15mm 16mm;
  @bottom-center { content: "Página " counter(page) " de " counter(pages); font: 9pt "Times New Roman", serif; color: #555; }
  @bottom-left { content: "SIC Servicios Integrales y Consultoría"; font: 8pt "Times New Roman", serif; color: #888; } }
@media print {
  html, body { background: #fff !important; }
  .lateral, .barra, .editor-barra, .titulo, .no-imprimir, #toasts, .modal-fondo { display: none !important; }
  .app { display: block; }
  .contenido { padding: 0; max-width: none; }
  .hoja-wrap { overflow: visible; padding: 0; }
  .hoja { box-shadow: none; padding: 0; width: auto; min-height: 0; margin: 0; }
  .doc * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc .salto { border: 0; margin: 0; }
  .doc .salto::after { display: none; }
}

/* ---------- celular */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .lateral { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .app.menu .lateral { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .barra { display: flex; align-items: center; gap: 10px; background: var(--navy); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 30; }
  .barra img { height: 28px; }
  .barra button { background: none; border: 0; color: #fff; padding: 4px; }
  .barra svg { width: 24px; height: 24px; }
  .contenido { padding: 16px 16px 50px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .titulo h1 { font-size: 20px; }
  .hoja { padding: 8mm 6mm; min-height: 0; }
  .editor-barra { flex-wrap: nowrap; overflow-x: auto; }
  .editor-barra .estado { white-space: nowrap; }
  .doc .doc-head img { height: 14mm; }
  .doc { font-size: 11pt; }
  .doc .hb { grid-template-columns: 26mm 1fr 22mm; }
}
@media (max-width: 520px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
