/* SIGRE - estilos propios sobre Bootstrap 5.3 */
:root {
  --sg-ink: #16202E;
  --sg-navy: #16202E;
  --sg-blue: #1D4E89;
  --sg-blue-dark: #123660;
  --sg-ground: #EEF1F4;
  --sg-line: #DCE2E8;
  --sg-muted: #4A5868;
  --bs-primary: #1D4E89;
  --bs-primary-rgb: 29, 78, 137;
  --bs-link-color: #1D4E89;
  --bs-link-color-rgb: 29, 78, 137;
  --bs-link-hover-color: #123660;
  --bs-body-font-family: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bs-body-color: #16202E;
  --bs-body-bg: #EEF1F4;
}
body { background: var(--sg-ground); }
.mono, .nro { font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.nro { font-weight: 600; }

.btn-primary { --bs-btn-bg: var(--sg-blue); --bs-btn-border-color: var(--sg-blue); --bs-btn-hover-bg: var(--sg-blue-dark); --bs-btn-hover-border-color: var(--sg-blue-dark); --bs-btn-active-bg: var(--sg-blue-dark); }
.btn-outline-primary { --bs-btn-color: var(--sg-blue); --bs-btn-border-color: #9DB3CF; --bs-btn-hover-bg: var(--sg-blue); --bs-btn-hover-border-color: var(--sg-blue); --bs-btn-active-bg: var(--sg-blue); --bs-btn-active-border-color: var(--sg-blue); }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: #5B8BC6; box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb),.2); }
.form-check-input:checked { background-color: var(--sg-blue); border-color: var(--sg-blue); }
.pagination { --bs-pagination-active-bg: var(--sg-blue); --bs-pagination-active-border-color: var(--sg-blue); --bs-pagination-color: var(--sg-blue); }
.btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-sm { min-height: 32px; }
.form-control, .form-select { min-height: 42px; border-color: #C8D1DA; }
.form-label { font-weight: 600; font-size: .85rem; color: #3E4A57; margin-bottom: .3rem; }

/* Estructura */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex: none; background: var(--sg-navy); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 3px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.content { flex: 1; min-width: 0; padding: 20px 28px 48px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 20px; text-decoration: none; }
.brand-logo { width: 40px; height: 40px; border-radius: 10px; background: var(--sg-blue); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.brand-name { color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .06em; }
.brand-sub { color: #93A3B6; font-size: 12px; }
.nav-item-link {
  display: flex; align-items: center; gap: 12px; padding: 0 12px; min-height: 44px; border-radius: 8px;
  color: #C3CDD9; text-decoration: none; font-size: 14px; font-weight: 500; cursor: pointer;
}
.nav-item-link:hover { background: #24344D; color: #fff; }
.nav-item-link.active { background: var(--sg-blue); color: #fff; }
.sidebar-user { margin-top: auto; padding-top: 18px; border-top: 1px solid #2B3A52; display: flex; flex-direction: column; gap: 4px; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.topbar-search { flex: 1; max-width: 520px; }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: -260px; z-index: 1040; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .content { padding: 14px 16px 40px; }
}

/* Componentes */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: 1.6rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.crumbs { font-size: .82rem; color: var(--sg-muted); }
.card { --bs-card-bg: #fff; border-color: var(--sg-line); border-radius: 12px; }
.list-group { --bs-list-group-bg: #fff; }
.modal { --bs-modal-bg: #fff; }
.form-control, .form-select { background-color: #fff; }
.dropdown-menu { --bs-dropdown-bg: #fff; }
.card-header { background: #fff; border-bottom-color: var(--sg-line); font-weight: 700; padding: 14px 18px; border-radius: 12px 12px 0 0 !important; }
.kpi { background: #fff; border: 1px solid var(--sg-line); border-radius: 12px; padding: 18px; height: 100%; }
.kpi .lbl { font-size: .82rem; color: var(--sg-muted); font-weight: 600; }
.kpi .val { font-size: 1.9rem; font-weight: 700; line-height: 1.1; margin-top: 6px; }
.kpi.warn { background: #FFF8EA; border-color: #EBCB8B; }
.kpi.warn .lbl, .kpi.warn .val { color: #7A4B00; }

.table { --bs-table-bg: #fff; margin: 0; }
.table thead th { font-size: .74rem; letter-spacing: .04em; text-transform: uppercase; color: var(--sg-muted); background: #F7F9FA; font-weight: 600; white-space: nowrap; }
.table td { vertical-align: middle; }
.table td.mono, .table td.text-end { white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.pais { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 22px; border-radius: 5px; font: 700 11px 'IBM Plex Mono', monospace; padding: 0 4px; }
.pais-CL { background: #FDE2E0; color: #9B1C1C; }
.pais-AR { background: #DCEFFB; color: #0B5A85; }
.pais-BR { background: #DDF3E3; color: #166534; }

.progress { height: 8px; background: #E4E9EE; }
.progress-bar { background: var(--sg-blue); }
.progress-bar.completo { background: #2F8A4E; }

.stepper { display: flex; list-style: none; padding: 0; margin: 0; min-width: 760px; }
.stepper li { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: .8rem; color: var(--sg-muted); }
.stepper .dot { width: 28px; height: 28px; border-radius: 50%; background: #E4E9EE; color: var(--sg-muted); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; }
.stepper .row-line { display: flex; align-items: center; }
.stepper .line { flex: 1; height: 2px; background: #DCE2E8; margin: 0 6px; }
.stepper li.done .dot { background: #2F8A4E; color: #fff; }
.stepper li.done .line { background: #2F8A4E; }
.stepper li.current .dot { background: var(--sg-blue); color: #fff; }
.stepper li.current { color: var(--sg-ink); font-weight: 700; }

.nav-tabs .nav-link { color: var(--sg-muted); font-weight: 600; min-height: 44px; }
.nav-tabs .nav-link.active { color: var(--sg-blue-dark); border-bottom: 3px solid var(--sg-blue); }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.dl-grid dt { font-size: .76rem; font-weight: 600; color: var(--sg-muted); }
.dl-grid dd { margin: 2px 0 0; }
.secret { font-family: 'IBM Plex Mono', monospace; letter-spacing: .05em; }
.alerta-item { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; background: #F7F9FA; border: 1px solid #EDF0F3; }
.alerta-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; }
.alerta-dot.danger { background: #B42318; }
.alerta-dot.warning { background: #C98A12; }
.alerta-dot.info { background: #5B8BC6; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 210px) 1fr 40px; gap: 10px; align-items: center; font-size: .9rem; }
.bar-track { height: 12px; background: #EEF1F4; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 12px; border-radius: 6px; background: var(--sg-blue); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; flex-wrap: wrap; }
.login-brand { flex: 1 1 420px; background: var(--sg-navy); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.login-form { flex: 1 1 420px; background: #fff; padding: 56px 24px; display: flex; align-items: center; justify-content: center; }
.login-form form { width: 100%; max-width: 380px; }
@media (max-width: 767.98px) { .login-brand { padding: 28px 20px; flex-basis: 100%; } .login-brand h1 { font-size: 1.7rem !important; } .login-form { padding: 32px 20px; } }
.chip { padding: 7px 14px; border-radius: 999px; border: 1px solid #3A4B66; font-size: .82rem; color: #DCE4EE; }

/* Impresión (ficha, recibo) */
@media print {
  .sidebar, .topbar, .no-print, .alert { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
  .hoja { border: 0; padding: 0; max-width: none; }
}

/* ---- v2: parametrización, responsivo y documentos ---- */
.brand img, .login-logo img { background: #fff; border-radius: 8px; padding: 3px; }
.login-logo { display: inline-flex; }
.pais-PE { background: #FDE4E6; color: #9F1239; }
.pais { background: #E9EDF1; color: #3E4A57; }
.pais-CL { background: #FDE2E0; color: #9B1C1C; } .pais-AR { background: #DCEFFB; color: #0B5A85; } .pais-BR { background: #DDF3E3; color: #166534; } .pais-PE { background: #FDE4E6; color: #9F1239; }
.tabs-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabs-scroll .nav-tabs { min-width: max-content; }
.card > .nav-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.card > .nav-tabs .nav-link { white-space: nowrap; }
.print-only { display: none; }

@media (max-width: 575.98px) {
  .page-head h1 { font-size: 1.3rem; }
  .page-head > div:last-child:not(:first-child) { width: 100%; }
  .page-head .btn { flex: 1 1 auto; }
  .kpi .val { font-size: 1.5rem; }
  .bar-row { grid-template-columns: minmax(100px, 1fr) 1.2fr 32px; font-size: .82rem; }
  .card-header { padding: 12px 14px; }
  .topbar-search { max-width: none; }
  .table { font-size: .85rem; }
  .hoja { padding: 16px; }
}

/* Documentos imprimibles */
.print-body { background: #E9EDF1; padding: 20px 12px 40px; }
.print-toolbar { max-width: 820px; margin: 0 auto 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.hoja { background: #fff; max-width: 820px; margin: 0 auto 20px; padding: 28px 34px; border: 1px solid var(--sg-line); box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.doc-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 3px solid var(--sg-blue); padding-bottom: 10px; margin-bottom: 12px; }
.doc-head-brand { display: flex; align-items: center; gap: 14px; }
.doc-logo { font-size: 1.1rem; }
.doc-empresa { font-size: 1.35rem; font-weight: 800; color: var(--sg-blue); line-height: 1.1; text-transform: uppercase; letter-spacing: .02em; }
.doc-sub { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: #3E4A57; }
.doc-datos { font-size: .72rem; color: #5A6878; margin-top: 2px; }
.doc-head-titulo { text-align: right; }
.doc-titulo { font-weight: 800; font-size: 1.15rem; color: var(--sg-blue); }
.doc-pie { margin-top: 14px; padding-top: 6px; border-top: 1px solid var(--sg-line); font-size: .7rem; color: #5A6878; text-align: center; }

.ficha-titulo { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; border: 1px solid #8A99AA; padding: 8px 12px; }
.ficha-banderas { display: flex; gap: 4px; }
.ficha-titulo h1 { margin: 0; text-align: center; font-family: Georgia, 'Times New Roman', serif; font-weight: 800; font-size: 1.35rem; color: var(--sg-blue); letter-spacing: .03em; }
.ficha-nro { display: flex; flex-direction: column; align-items: flex-end; font-size: .7rem; color: #5A6878; }
.ficha-nro b { font-size: .95rem; color: var(--sg-ink); }
.ficha-tramite { font-size: .75rem; color: #3E4A57; padding: 3px 12px; border: 1px solid #8A99AA; border-top: 0; }
.ficha-tabla { width: 100%; border-collapse: collapse; font-size: .82rem; margin-top: -1px; }
.ficha-tabla th, .ficha-tabla td { border: 1px solid #8A99AA; padding: 4px 8px; vertical-align: middle; }
.ficha-tabla th { width: 36%; text-align: center; font-family: Georgia, 'Times New Roman', serif; font-weight: 400; font-size: .9rem; }
.ficha-tabla th.ficha-resaltado { color: var(--sg-blue); }
.ficha-sub { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; padding: 3px 8px; }
.ficha-sub + .ficha-sub { border-top: 1px solid #C8D1DA; }
.ficha-sub span { color: #3E4A57; font-size: .78rem; }
.opciones { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: .74rem; }
.opciones span { display: inline-flex; align-items: center; gap: 4px; }
.casilla { display: inline-flex; align-items: center; justify-content: center; width: 13px; height: 13px; border: 1px solid #3E4A57; font-size: 10px; line-height: 1; font-weight: 700; }
.casilla.on { background: #EAF1FA; color: var(--sg-blue-dark); }
.ficha-declaracion { font-size: .68rem; text-align: justify; margin: 6px 0; line-height: 1.35; }
.ficha-pie { display: grid; grid-template-columns: 1.1fr .9fr 1.3fr; border: 1px solid #8A99AA; }
.ficha-firma { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding: 10px; min-height: 120px; border-right: 1px solid #8A99AA; text-align: center; }
.ficha-firma .linea { border-top: 1px solid #000; width: 90%; padding-top: 4px; font-family: Georgia, serif; color: var(--sg-blue); font-weight: 700; }
.ficha-pago, .ficha-docs { width: 100%; border-collapse: collapse; font-size: .74rem; }
.ficha-pago th, .ficha-pago td, .ficha-docs th, .ficha-docs td { border: 1px solid #8A99AA; padding: 3px 6px; }
.ficha-pago { border-right: 1px solid #8A99AA; }
.ficha-pago th { width: 40%; font-weight: 700; }
.ficha-docs th { font-weight: 600; }
.ficha-docs td { width: 30px; }
.ficha-constancia { margin-top: 14px; }
.ficha-constancia h2 { font-size: .95rem; font-weight: 700; color: var(--sg-blue); margin-bottom: 6px; }
.ficha-firmas { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 46px; }
.ficha-firmas .linea { border-top: 1px solid #000; padding-top: 4px; text-align: center; font-size: .78rem; }

@media (max-width: 640px) {
  .ficha-titulo { grid-template-columns: 1fr; text-align: center; }
  .ficha-banderas, .ficha-nro { justify-content: center; align-items: center; }
  .ficha-titulo h1 { font-size: 1.05rem; }
  .ficha-tabla th { width: 40%; font-size: .78rem; }
  .ficha-pie { grid-template-columns: 1fr; }
  .ficha-firma { border-right: 0; border-bottom: 1px solid #8A99AA; }
  .doc-head-titulo { text-align: left; }
  .ficha-firmas { gap: 16px; }
}

@media print {
  @page { size: A4; margin: 10mm; }
  .print-body { background: #fff; padding: 0; }
  .print-toolbar { display: none !important; }
  .hoja { box-shadow: none; border: 0; padding: 0; margin: 0; max-width: none; }
  .hoja.salto { page-break-before: always; break-before: page; }
  .ficha-constancia { break-inside: avoid; }
  .print-only { display: block !important; }
  .no-print { display: none !important; }
  .card { border: 0; }
  .table-wrap { overflow: visible; }
  a { color: inherit; text-decoration: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.doc-head-brand { min-width: 0; flex-wrap: wrap; }
.doc-head-brand > div { min-width: 0; }
.doc-empresa { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .print-body { padding: 10px 6px 30px; }
  .hoja { padding: 14px 12px; }
  .doc-head-brand img { max-width: 160px !important; height: auto !important; max-height: 58px; }
  .doc-empresa { font-size: 1.05rem; }
  .ficha-tabla { font-size: .76rem; }
  .ficha-constancia .table { font-size: .7rem; }
}
.brand img { max-width: 96px !important; max-height: 44px; }
.sidebar .brand-sub { overflow-wrap: anywhere; }
.topbar { flex-wrap: wrap; }
.topbar-search { flex: 1 1 220px; }
@media (max-width: 575.98px) { .topbar > .ms-auto { margin-left: 0 !important; width: 100%; } .topbar > .ms-auto form, .topbar > .ms-auto select { flex: 1; } }
.list-group { --bs-list-group-active-bg: var(--sg-blue); --bs-list-group-active-border-color: var(--sg-blue); }
.btn-check:checked + .btn-outline-primary { background: var(--sg-blue); border-color: var(--sg-blue); color: #fff; }
