/* ==========================================================================
   Docudi · Sistema de diseño (capa sobre Bootstrap 5.3)
   Estilo "hoja enmarcada": un marco tenue (tono de la marca) contiene el menú y la
   barra superior; el trabajo vive en una hoja blanca con borde fino y sin sombra.
   El color va en los datos y en el estado, no en el cromo.
   ========================================================================== */

/* ---- Tipografía propia (sin terceros: funciona en intranet sin internet) ---- */
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

:root {
  /* Superficies */
  --frame: #eff3f7;          /* marco: un paso tenue del azul Docudi */
  --surface: #ffffff;        /* la hoja */
  --raised: #f6f8fb;
  --active: #e1e8f0;         /* píldora del menú y fila seleccionada */
  --border: #e1e6ed;         /* borde de la hoja y de las tarjetas */
  --rule: #edf1f5;           /* separador de filas */
  --control: #cbd3dd;        /* borde de campos y botones secundarios */

  /* Texto (todas las capas ≥ 4.5:1 sobre blanco) */
  --text: #142132;
  --muted: #536173;
  --faint: #66717f;

  /* Marca y datos */
  --brand: #1b3a5f;          /* acción principal */
  --brand-hover: #142d4a;
  --accent: #2763a7;         /* el único tono de datos: serie principal, selección, enlaces */
  --accent-soft: #e6eef8;
  --focus: rgba(39, 99, 167, .32);

  /* Estados (pares pálidos: fondo + tinta del mismo tono) */
  --ok-bg: #dcf2e4;      --ok-ink: #0f4a2b;      --ok: #237a4b;
  --aviso-bg: #fbf0d2;   --aviso-ink: #6e4600;   --aviso: #a26a00;
  --error-bg: #fbe7e5;   --error-ink: #8a1d18;   --error: #c0322b;
  --info-bg: #e3edf9;    --info-ink: #143f6e;
  --neutro-bg: #edf0f4;  --neutro-ink: #3f4a58;

  /* Forma y ritmo */
  --radius-sheet: 16px; --radius-card: 12px; --radius-control: 8px; --radius-chip: 999px;
  --gap: 16px; --pad: 24px;
  --side-w: 236px; --top-h: 52px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  /* Movimiento: salida fuerte y corta para todo lo que responde al usuario */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  /* Bootstrap sobre los tokens */
  --bs-body-font-family: var(--font);
  --bs-body-font-size: .875rem;
  --bs-body-line-height: 1.45;
  --bs-body-color: var(--text);
  --bs-body-bg: var(--surface);      /* superficies de Bootstrap (campos, menús, modales) en blanco */
  --bs-emphasis-color: var(--text);
  --bs-secondary-color: var(--muted);
  --bs-tertiary-color: var(--faint);
  --bs-border-color: var(--border);
  --bs-border-radius: var(--radius-control);
  --bs-border-radius-lg: var(--radius-card);
  --bs-link-color: var(--accent);
  --bs-link-color-rgb: 39, 99, 167;
  --bs-link-hover-color: #1d4e86;
  --bs-link-hover-color-rgb: 29, 78, 134;
  --bs-primary: var(--brand);
  --bs-primary-rgb: 27, 58, 95;
  --bs-focus-ring-color: var(--focus);
  --bs-heading-color: var(--text);
}

html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--frame); color: var(--text); font-feature-settings: "kern"; text-rendering: optimizeLegibility; }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
a { text-underline-offset: 2px; }
::selection { background: #cfe0f5; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.text-muted, .text-body-secondary { color: var(--muted) !important; }
.small, small { font-size: .8125rem; }
.num, .table td.num, .table th.num { font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; }
.id-code { font-family: var(--mono); font-weight: 500; font-size: .8125rem; letter-spacing: -0.01em; white-space: nowrap; color: var(--text); }
a .id-code, a.id-code { color: inherit; }
.dash { color: var(--faint); }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 2000; background: var(--brand); color: #fff; padding: 8px 12px; border-radius: 8px; transition: top 150ms var(--ease-out); }
.skip-link:focus { top: 12px; }

/* ==========================================================================
   Marco de la aplicación
   ========================================================================== */
.app-shell { display: flex; min-height: 100vh; }
.app-side { width: var(--side-w); flex: 0 0 var(--side-w); background: var(--frame); }
.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

@media (min-width: 992px) {
  .app-side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
  .app-side .offcanvas-body { display: contents; }
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 10px 20px; }
.side-brand img { display: block; width: 132px; height: auto; }
.side-scope { margin: 4px 12px 12px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.65); border: 1px solid var(--border); }
.side-scope .scope-label { display: block; font-size: .75rem; color: var(--muted); }
.side-scope .scope-name { display: block; font-size: .8125rem; font-weight: 500; line-height: 1.3; color: var(--text); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.side-nav { padding: 4px 10px 12px; flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.side-group { font-size: .75rem; color: var(--muted); padding: 18px 10px 6px; }
.side-group:first-child { padding-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; margin-bottom: 1px;
  border-radius: 8px; color: #364354; text-decoration: none; font-size: .875rem;
  transition: background-color 150ms ease, color 150ms ease;
}
.nav-item i { font-size: 1rem; width: 18px; text-align: center; color: #5d6a7b; }
.nav-item span:first-of-type { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (hover: hover) and (pointer: fine) { .nav-item:hover { background: rgba(27, 58, 95, .06); color: var(--text); } }
.nav-item.is-active { background: var(--active); color: var(--text); font-weight: 500; }
.nav-item.is-active i { color: var(--text); }
.nav-count { flex: none; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: .75rem; font-weight: 500; line-height: 20px; text-align: center; background: #dfe5ed; color: #2b3747; font-variant-numeric: tabular-nums; }
.nav-count.is-alerta { background: var(--error); color: #fff; }
.side-foot { padding: 10px 12px 14px; border-top: 1px solid var(--border); margin: 0 10px; padding-left: 0; padding-right: 0; }
.user-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: 0; background: transparent; border-radius: 10px; text-align: left; color: var(--text); transition: background-color 150ms ease; }
@media (hover: hover) and (pointer: fine) { .user-btn:hover { background: rgba(27, 58, 95, .06); } }
.avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .75rem; font-weight: 600; background: #d8e3f1; color: #1b3a5f; }
.user-btn .u-name { display: block; font-size: .8125rem; font-weight: 500; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.user-btn .u-rol { display: block; font-size: .75rem; color: var(--muted); }
.side-credit { font-size: .75rem; color: var(--faint); padding: 8px 8px 0; }

/* Barra superior: sobre el mismo marco, sin regla que la separe del menú */
.app-top { height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 8px 0 0; }
.top-title { font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-search { position: relative; flex: 0 1 560px; margin: 0 auto; }
.top-search .bi-search { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: .875rem; pointer-events: none; }
.top-search input { width: 100%; height: 34px; padding: 0 44px 0 34px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: .875rem; color: var(--text); transition: border-color 150ms ease, box-shadow 150ms ease; }
.top-search input::placeholder { color: var(--faint); }
.top-search input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.top-search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-family: var(--font); font-size: .75rem; color: var(--muted); background: var(--raised); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; box-shadow: none; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.btn-icon { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--text); font-size: 1.25rem; transition: background-color 150ms ease, transform 120ms var(--ease-out); }
.btn-icon:active { transform: scale(.96); }
@media (hover: hover) and (pointer: fine) { .btn-icon:hover { background: rgba(27, 58, 95, .07); } }

/* La hoja de trabajo */
.app-sheet { flex: 1 1 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sheet); margin: 0 8px 8px 0; padding: 24px 28px 32px; min-width: 0; }
.app-sheet:focus { outline: 0; }

@media (max-width: 991.98px) {
  :root { --pad: 16px; }
  .app-shell { display: block; }
  .app-side { width: min(320px, 86vw); }
  .app-side.offcanvas-lg { background: var(--frame); }
  .app-side .offcanvas-body { display: flex; flex-direction: column; padding: 0; overflow-y: auto; }
  .app-top { position: sticky; top: 0; z-index: 1020; height: 52px; padding: 0 8px; background: var(--frame); }
  .top-search { display: none; position: absolute; left: 8px; right: 8px; top: 8px; margin: 0; z-index: 2; }
  .app-top.is-buscando .top-search { display: block; }
  .app-top.is-buscando .top-search input { height: 36px; }
  .app-sheet { margin: 0; border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0; padding: 18px 16px 28px; min-height: calc(100vh - 52px); }
}
@media (min-width: 992px) { .solo-movil { display: none !important; } }

/* ==========================================================================
   Encabezado de pantalla
   ========================================================================== */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 16px; margin-bottom: 20px; }
.page-head > div:first-child { min-width: 0; }
.page-title { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; margin: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; }
.page-sub { color: var(--muted); font-size: .875rem; margin: 4px 0 0; max-width: 72ch; }
.page-sub strong { color: var(--text); font-weight: 600; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.breadcrumb-app { font-size: .8125rem; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.breadcrumb-app a { color: var(--muted); text-decoration: none; }
.breadcrumb-app a:hover { color: var(--text); }
@media (max-width: 575.98px) { .page-title { font-size: 1.25rem; } .page-actions { width: 100%; } }
/* Bootstrap: títulos heredados h1.h3 de las pantallas administrativas */
.app-sheet > .d-flex > h1.h3, .app-sheet > h1.h3 { font-size: 1.5rem; }

/* ==========================================================================
   Tarjetas, bloques y KPIs
   ========================================================================== */
.card { --bs-card-border-color: var(--border); --bs-card-border-radius: var(--radius-card); --bs-card-inner-border-radius: calc(var(--radius-card) - 1px); --bs-card-cap-bg: transparent; --bs-card-bg: var(--surface); border: 1px solid var(--border); box-shadow: none; }
.card-header { background: transparent !important; border-bottom: 1px solid var(--rule); padding: 14px 18px; font-size: .9375rem; }
.card-header strong, .card-header .card-title { font-weight: 600; }
.card-body { padding: 18px; }
.card-footer { background: transparent; border-top: 1px solid var(--rule); }
.card.p-3 { padding: 18px !important; }
.bloque-titulo { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.bloque-titulo h2 { font-size: 1rem; font-weight: 600; margin: 0; }
.bloque-titulo .meta { font-size: .8125rem; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); margin-bottom: 24px; }
.kpi { padding: 16px 20px; min-width: 0; text-decoration: none; color: inherit; position: relative; transition: background-color 150ms ease; }
.kpi + .kpi { border-left: 1px solid var(--border); }
a.kpi:hover { background: var(--raised); }
.kpi .kpi-label { display: block; font-size: .8125rem; color: var(--muted); }
.kpi .kpi-valor { display: block; font-size: 1.75rem; font-weight: 500; line-height: 1.25; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpi .kpi-nota { display: block; font-size: .75rem; color: var(--muted); margin-top: 2px; }
.kpi.is-alerta .kpi-valor { color: var(--error); }
.kpi.is-lider .kpi-valor { font-size: 2.125rem; }
@media (max-width: 767.98px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi + .kpi { border-left: 0; }
  .kpi:nth-child(even) { border-left: 1px solid var(--border); }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--border); }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi .kpi-valor { font-size: 1.5rem; }
}

/* ==========================================================================
   Tablas: reglas y alineación (sin cebra, sin banda de encabezado)
   ========================================================================== */
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-border-color: var(--rule); --bs-table-hover-bg: #f6f9fc; --bs-table-hover-color: var(--text); --bs-table-striped-bg: transparent; margin-bottom: 0; font-size: .875rem; }
.table > :not(caption) > * > * { padding: 11px 12px; border-bottom-color: var(--rule); }
.table > thead > tr > th, .table thead.table-light th, .table > thead th {
  --bs-table-bg: transparent; background: transparent; color: var(--muted); font-size: .8125rem; font-weight: 500;
  text-transform: none; letter-spacing: 0; white-space: nowrap; border-bottom: 1px solid var(--border); padding-top: 10px; padding-bottom: 10px;
}
.table > tbody > tr:last-child > * { border-bottom: 0; }
.table > tbody > tr > td:first-child, .table > thead > tr > th:first-child { padding-left: 18px; }
.table > tbody > tr > td:last-child, .table > thead > tr > th:last-child { padding-right: 18px; }
.table-hover > tbody > tr { transition: background-color 120ms ease; }
.table td .sub { display: block; font-size: .8125rem; color: var(--muted); margin-top: 2px; }
.table .acciones-fila { text-align: right; white-space: nowrap; width: 1%; }
.fila-link { cursor: pointer; }
.table-responsive { scrollbar-width: thin; }
.total-filas { font-size: .8125rem; color: var(--muted); }

/* ==========================================================================
   Estados: píldoras pálidas (Bootstrap .badge reasignado a pares de tono)
   ========================================================================== */
.badge { --bs-badge-font-weight: 500; --bs-badge-font-size: .75rem; --bs-badge-padding-x: .55rem; --bs-badge-padding-y: .28rem; border-radius: var(--radius-chip); white-space: nowrap; flex: none; letter-spacing: 0; line-height: 1.2; vertical-align: middle; }
.badge.bg-success, .badge.text-bg-success, .badge.bg-ok { background: var(--ok-bg) !important; color: var(--ok-ink) !important; }
.badge.bg-warning, .badge.text-bg-warning, .badge.bg-aviso { background: var(--aviso-bg) !important; color: var(--aviso-ink) !important; }
.badge.bg-danger, .badge.text-bg-danger, .badge.bg-error { background: var(--error-bg) !important; color: var(--error-ink) !important; }
.badge.bg-info, .badge.text-bg-info, .badge.bg-primary, .badge.text-bg-primary, .badge.bg-info-app { background: var(--info-bg) !important; color: var(--info-ink) !important; }
.badge.bg-secondary, .badge.text-bg-secondary, .badge.bg-dark, .badge.text-bg-dark, .badge.bg-light, .badge.bg-neutro { background: var(--neutro-bg) !important; color: var(--neutro-ink) !important; }
.badge.bg-tipo { background: transparent !important; color: var(--muted) !important; border: 1px solid var(--control); font-weight: 500; }
.badge i { margin-right: 3px; }
.badge.fs-6 { font-size: .8125rem !important; padding: .35rem .7rem; }
/* Semáforo de términos: el rojo solo en lo vencido */
.termino { display: inline-flex; flex-direction: column; gap: 1px; }
.termino .t-fecha { font-variant-numeric: tabular-nums; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.termino .t-texto { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.punto { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; background: var(--control); }
.punto.is-danger { background: var(--error); }
.punto.is-warning { background: #d99a00; }
.punto.is-success { background: var(--ok); }
.termino.is-danger .t-texto { color: var(--error-ink); font-weight: 500; }

/* ==========================================================================
   Botones: uno principal (marca), el resto contorno neutro; presión con escala
   ========================================================================== */
.btn { --bs-btn-font-weight: 500; --bs-btn-font-size: .875rem; --bs-btn-padding-y: .45rem; --bs-btn-padding-x: .9rem; --bs-btn-border-radius: var(--radius-control); --bs-btn-focus-box-shadow: 0 0 0 3px var(--focus);
  transition: transform 120ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn > .bi { line-height: 1; }
.btn .me-1 { margin-right: 0 !important; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn-sm { --bs-btn-padding-y: .3rem; --bs-btn-padding-x: .65rem; --bs-btn-font-size: .8125rem; --bs-btn-border-radius: 7px; }
.btn-lg { --bs-btn-padding-y: .65rem; --bs-btn-padding-x: 1.1rem; --bs-btn-font-size: .9375rem; --bs-btn-border-radius: 10px; }
.btn-primary, .btn-success {
  --bs-btn-color: #fff; --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--brand-hover); --bs-btn-hover-border-color: var(--brand-hover);
  --bs-btn-active-color: #fff; --bs-btn-active-bg: #0f243c; --bs-btn-active-border-color: #0f243c;
  --bs-btn-disabled-color: #fff; --bs-btn-disabled-bg: #7d8ea3; --bs-btn-disabled-border-color: #7d8ea3;
}
.btn-outline-primary, .btn-outline-secondary, .btn-outline-success, .btn-outline-info, .btn-outline-dark, .btn-light, .btn-outline-warning {
  --bs-btn-color: var(--text); --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--control);
  --bs-btn-hover-color: var(--text); --bs-btn-hover-bg: #f2f5f9; --bs-btn-hover-border-color: #b7c1ce;
  --bs-btn-active-color: var(--text); --bs-btn-active-bg: #e8edf3; --bs-btn-active-border-color: #b7c1ce;
  --bs-btn-disabled-color: var(--faint); --bs-btn-disabled-bg: var(--surface); --bs-btn-disabled-border-color: var(--border);
}
.btn-outline-danger {
  --bs-btn-color: var(--error-ink); --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--control);
  --bs-btn-hover-color: var(--error-ink); --bs-btn-hover-bg: #fdf1f0; --bs-btn-hover-border-color: #e3b4b0;
  --bs-btn-active-color: var(--error-ink); --bs-btn-active-bg: var(--error-bg); --bs-btn-active-border-color: #e3b4b0;
}
.btn-danger { --bs-btn-bg: var(--error); --bs-btn-border-color: var(--error); --bs-btn-hover-bg: #a5281f; --bs-btn-hover-border-color: #a5281f; --bs-btn-active-bg: #8a1d18; --bs-btn-active-border-color: #8a1d18; }
.btn-secondary { --bs-btn-color: var(--text); --bs-btn-bg: #e8edf3; --bs-btn-border-color: #e8edf3; --bs-btn-hover-color: var(--text); --bs-btn-hover-bg: #dde4ec; --bs-btn-hover-border-color: #dde4ec; --bs-btn-active-color: var(--text); --bs-btn-active-bg: #d2dae4; --bs-btn-active-border-color: #d2dae4; }
.btn-link { --bs-btn-color: var(--accent); text-decoration: none; }
.btn.is-cargando { pointer-events: none; opacity: .8; }
.btn .spinner-border { width: 14px; height: 14px; border-width: 2px; }

/* ==========================================================================
   Formularios
   ========================================================================== */
.form-label { font-size: .8125rem; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.form-control, .form-select { font-size: .875rem; min-height: 38px; border-color: var(--control); border-radius: var(--radius-control); color: var(--text); transition: border-color 150ms ease, box-shadow 150ms ease; }
.form-control::placeholder { color: var(--faint); }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.form-control-sm, .form-select-sm { min-height: 32px; font-size: .8125rem; border-radius: 7px; }
.form-control-lg, .form-select-lg { min-height: 44px; font-size: .9375rem; border-radius: 10px; }
.form-text { color: var(--muted); font-size: .75rem; }
.form-check-input { border-color: var(--control); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-control.is-invalid, .form-select.is-invalid, .was-validated .form-control:invalid, .was-validated .form-select:invalid { border-color: var(--error); }
.invalid-feedback { color: var(--error-ink); font-size: .75rem; }
.filtros { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; margin-bottom: 14px; }
.filtros .campo { display: flex; flex-direction: column; min-width: 150px; flex: 0 1 180px; }
.filtros .campo-busqueda { flex: 1 1 260px; max-width: 360px; position: relative; }
.filtros .campo-busqueda .bi-search { position: absolute; left: 11px; bottom: 9px; color: var(--faint); font-size: .8125rem; pointer-events: none; }
.filtros .campo-busqueda input { padding-left: 32px; }
.filtros label { font-size: .75rem; color: var(--muted); margin-bottom: 4px; }
.filtros .checks { display: flex; gap: 14px; align-items: center; min-height: 32px; }
.filtros .checks .form-check-label { font-size: .8125rem; color: var(--text); }

@media (max-width: 767.98px) {
  .filtros { gap: 8px; }
  .filtros .campo-busqueda { flex: 1 1 0; max-width: none; }
  .filtros .campo:not(.campo-busqueda) { display: none; flex: 1 1 calc(50% - 8px); min-width: 0; }
  .filtros.is-abierto .campo { display: flex; }
  .filtros .btn-filtros { align-self: flex-end; height: 32px; }
  .filtros .campo-busqueda label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

/* Tablas que en el celular pasan a filas de dos líneas (nunca se pierde un campo) */
@media (max-width: 640px) {
  .tabla-apilada thead { display: none; }
  .tabla-apilada tbody tr:not(.fila-vacia) {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "check num estado" "check asunto asunto" "check dep term";
    gap: 4px 10px; padding: 12px 14px; border-bottom: 1px solid var(--rule);
  }
  .tabla-apilada tbody tr.fila-vacia, .tabla-apilada tbody tr.fila-vacia td { display: block; }
  .tabla-apilada tbody tr:not(.fila-vacia) > td { display: block; padding: 0 !important; border: 0 !important; max-width: none !important; min-width: 0; }
  .tabla-apilada .c-check { grid-area: check; padding-top: 2px !important; }
  .tabla-apilada .c-num { grid-area: num; }
  .tabla-apilada .c-num .sub { display: inline; margin-left: 6px; }
  .tabla-apilada .c-estado { grid-area: estado; text-align: right; }
  .tabla-apilada .c-asunto { grid-area: asunto; }
  .tabla-apilada .c-dep { grid-area: dep; font-size: .8125rem; color: var(--muted); }
  .tabla-apilada .c-dep .sub { display: none; }
  .tabla-apilada .c-term { grid-area: term; text-align: right; }
  .tabla-apilada .c-term .termino { align-items: flex-end; }
  .tabla-apilada .c-term .t-texto { display: none; }
}

/* Pestañas subrayadas sobre una regla completa */
.tabs-linea, .nav-tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; --bs-nav-tabs-border-width: 0; }
.tabs-linea a, .nav-tabs .nav-link { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 10px 0 11px; color: var(--muted); text-decoration: none; font-size: .875rem; white-space: nowrap; border: 0 !important; background: transparent !important; margin: 0; }
.tabs-linea a:hover, .nav-tabs .nav-link:hover { color: var(--text); }
.tabs-linea a.is-activa, .nav-tabs .nav-link.active { color: var(--text); font-weight: 500; }
.tabs-linea a.is-activa::after, .nav-tabs .nav-link.active::after { content: ""; position: absolute; left: -4px; right: -4px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand); }
.tabs-linea .nav-count { height: 18px; line-height: 18px; min-width: 20px; font-size: .6875rem; }

/* ==========================================================================
   Avisos, modales, menús, paginación
   ========================================================================== */
.alert { border-radius: 10px; font-size: .875rem; padding: 10px 14px; border: 1px solid transparent; }
.alert-success { background: var(--ok-bg); color: var(--ok-ink); border-color: #bfe3cc; }
.alert-danger { background: var(--error-bg); color: var(--error-ink); border-color: #f1c3be; }
.alert-warning { background: #fff8e6; color: var(--aviso-ink); border-color: #f4dc9c; }
.alert-info, .alert-primary, .alert-secondary, .alert-light { background: var(--info-bg); color: var(--info-ink); border-color: #c9dbf1; }
.js .flash-msg { display: none; }

.modal { --bs-modal-border-radius: 14px; --bs-modal-inner-border-radius: 13px; --bs-modal-border-width: 0; --bs-modal-box-shadow: 0 24px 60px rgba(15, 33, 55, .22); --bs-modal-header-border-width: 0; --bs-modal-footer-border-width: 0; --bs-modal-padding: 20px; }
.modal-content { box-shadow: var(--bs-modal-box-shadow); }
.modal-header { padding: 18px 20px 6px; }
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-footer { padding: 6px 20px 18px; gap: 8px; }
.modal-footer > * { margin: 0; }
.modal-backdrop { --bs-backdrop-bg: #0f2137; --bs-backdrop-opacity: .38; }
.modal.fade .modal-dialog { transform: translateY(10px) scale(.98); transition: transform 220ms var(--ease-out); }
.modal.show .modal-dialog { transform: none; }
.modal.fade { transition: opacity 180ms ease; }

.dropdown-menu { --bs-dropdown-border-color: var(--border); --bs-dropdown-border-radius: 10px; --bs-dropdown-font-size: .875rem; --bs-dropdown-link-active-bg: var(--active); --bs-dropdown-link-active-color: var(--text); --bs-dropdown-link-hover-bg: #f2f5f9; box-shadow: 0 12px 32px rgba(15, 33, 55, .14); padding: 6px; }
.dropdown-item { border-radius: 7px; padding: 7px 10px; display: flex; align-items: center; gap: 8px; }
.dropdown-menu.show { animation: menu-in 160ms var(--ease-out); }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

.pagination { --bs-pagination-color: var(--text); --bs-pagination-border-width: 0; --bs-pagination-bg: transparent; --bs-pagination-hover-bg: #eef2f7; --bs-pagination-hover-color: var(--text); --bs-pagination-active-bg: var(--active); --bs-pagination-active-color: var(--text); --bs-pagination-disabled-bg: transparent; --bs-pagination-disabled-color: #9aa5b3; --bs-pagination-focus-box-shadow: 0 0 0 3px var(--focus); gap: 2px; }
.pagination .page-link { border-radius: 8px !important; min-width: 32px; height: 32px; display: grid; place-items: center; font-variant-numeric: tabular-nums; font-size: .8125rem; }
.page-item.active .page-link { font-weight: 600; }
.paginacion-pie { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.paginacion-pie nav { margin-top: 0 !important; }

.list-group { --bs-list-group-border-color: var(--rule); }

/* Barra de términos: partes de un todo, uniones de 2 px, sin etiquetas sobre los segmentos */
.barra-terminos { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; background: var(--rule); }
.barra-terminos span { display: block; min-width: 4px; }
.leyenda-tabla td { padding: 8px 0 !important; border-bottom: 1px solid var(--rule) !important; }
.leyenda-tabla tr:last-child td { border-bottom: 0 !important; }
.leyenda-tabla td.num { width: 64px; }
.leyenda-tabla .punto { margin-right: 6px; }

/* Gráficos: el espacio final reservado, en gris plano, hasta que se dibujan */
.grafico { position: relative; }
.grafico.is-pendiente { background: #eef2f6; border-radius: 8px; animation: sk-pulso 1.2s ease-in-out infinite; }
.grafico.is-pendiente canvas { visibility: hidden; }

/* Lista de carga: una cifra por fila y una barra fina gris bajo la etiqueta */
.lista-carga { list-style: none; margin: 0; padding: 0; }
.lista-carga li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 6px 0 8px; }
.lista-carga .lc-nombre { font-size: .875rem; }
.lista-carga .lc-valor { font-size: .875rem; text-align: right; }
.lista-carga .lc-barra { grid-column: 1 / -1; height: 3px; border-radius: 2px; background: #c3ccd8; }
.lista-carga li:first-child .lc-barra { background: var(--text); }

/* Pares clave–valor del detalle */
.kv { display: grid; grid-template-columns: minmax(140px, 200px) 1fr; gap: 0; margin: 0; }
.kv dt, .kv dd { padding: 9px 0; border-bottom: 1px solid var(--rule); margin: 0; font-size: .875rem; }
.kv dt { color: var(--muted); font-weight: 400; padding-right: 16px; }
.kv dd { color: var(--text); min-width: 0; }
.kv > :nth-last-child(-n+2) { border-bottom: 0; }
@media (max-width: 575.98px) { .kv { grid-template-columns: 1fr; } .kv dt { border-bottom: 0; padding-bottom: 0; } }

/* Línea de tiempo (trazabilidad) */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--control); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline li:first-child::before { border-color: var(--accent); background: var(--accent); }
.timeline .tl-titulo { font-weight: 500; font-size: .875rem; }
.timeline .tl-meta { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline .tl-detalle { font-size: .8125rem; color: #35414f; margin-top: 2px; }

/* Estados vacíos y de error: conservan el marco y explican el siguiente paso */
.estado-vacio { border: 1px dashed var(--control); border-radius: 10px; padding: 22px 20px; text-align: center; color: var(--muted); font-size: .875rem; }
.estado-vacio strong { display: block; color: var(--text); font-weight: 500; margin-bottom: 2px; }
.panel-error { max-width: 560px; margin: 8vh auto; text-align: left; }
.panel-error .codigo { font-family: var(--mono); font-size: .8125rem; color: var(--muted); }
.panel-error h1 { font-size: 1.5rem; margin: 6px 0 8px; }
.panel-error p { color: #35414f; font-size: .9375rem; }
.panel-error .soporte { font-size: .75rem; color: var(--faint); margin-top: 22px; }

/* ==========================================================================
   Notificaciones dentro de la app (reemplazan alert() y los avisos del navegador)
   ========================================================================== */
.toaster { position: fixed; right: 16px; bottom: 16px; z-index: 1090; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast-app {
  pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 12px 12px 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 14px 36px rgba(15, 33, 55, .16);
  font-size: .875rem; color: var(--text);
  opacity: 1; transform: translateY(0); transition: opacity 240ms ease, transform 240ms var(--ease-out);
}
@starting-style { .toast-app { opacity: 0; transform: translateY(10px); } }
.toast-app.is-saliendo { opacity: 0; transform: translateY(6px); transition-duration: 160ms; }
.toast-app .t-icono { flex: none; font-size: 1rem; line-height: 1.35; }
.toast-app.is-success .t-icono { color: var(--ok); }
.toast-app.is-danger .t-icono { color: var(--error); }
.toast-app.is-warning .t-icono { color: var(--aviso); }
.toast-app.is-info .t-icono { color: var(--accent); }
.toast-app .t-texto { flex: 1 1 auto; line-height: 1.4; padding-top: 1px; }
.toast-app .t-accion { flex: none; border: 0; background: none; color: var(--accent); font-weight: 500; font-size: .8125rem; padding: 2px 4px; }
.toast-app .t-cerrar { flex: none; border: 0; background: none; color: var(--faint); padding: 0 2px; font-size: 1rem; line-height: 1; }
@media (max-width: 575.98px) { .toaster { left: 16px; right: 16px; width: auto; bottom: 12px; } }

/* ==========================================================================
   Esqueletos de carga: el diseño final con barras grises planas en su lugar
   ========================================================================== */
.sk { display: inline-block; height: .8em; width: 100%; max-width: 100%; border-radius: 4px; background: #e8edf3; vertical-align: middle; animation: sk-pulso 1.2s ease-in-out infinite; }
.sk.sk-linea { display: block; height: 10px; margin: 4px 0; }
.sk.sk-bloque { display: block; height: 100%; min-height: 120px; border-radius: 10px; }
@keyframes sk-pulso { 50% { opacity: .55; } }
[aria-busy="true"] .sk-oculto { visibility: hidden; }
.visor-skeleton { position: absolute; inset: 0; padding: 32px; display: grid; place-items: center; background: #eef1f5; transition: opacity 200ms ease; }
.visor-skeleton .pagina-sk { width: min(640px, 90%); aspect-ratio: 8.5 / 11; max-height: 100%; background: #fff; border-radius: 6px; padding: 9% 8%; display: flex; flex-direction: column; gap: 12px; }
.visor-skeleton.is-listo { opacity: 0; pointer-events: none; }

/* Autocompletado y buscador global */
.ac-panel { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 1060; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 16px 40px rgba(15, 33, 55, .16); padding: 6px; max-height: min(440px, 70vh); overflow-y: auto; transform-origin: top center; animation: menu-in 150ms var(--ease-out); }
.ac-grupo { font-size: .75rem; color: var(--muted); padding: 8px 10px 4px; }
.ac-item { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; cursor: pointer; }
.ac-item .ac-titulo { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; }
.ac-item .ac-meta { flex: none; font-size: .75rem; color: var(--muted); }
.ac-item .id-code { flex: none; }
.ac-item.is-activo, .ac-item:hover { background: var(--accent-soft); }
.ac-item mark { background: #fff1b8; color: inherit; padding: 0 1px; border-radius: 2px; }
.ac-pie { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--rule); margin-top: 6px; padding: 8px 10px 4px; font-size: .8125rem; }
.ac-vacio { padding: 12px 10px; font-size: .8125rem; color: var(--muted); }
.ac-campo { position: relative; }

/* Filas que se retiran (interfaz optimista) */
tr.is-retirando, .is-retirando { opacity: 0; transform: translateX(8px); transition: opacity 200ms ease, transform 200ms var(--ease-out); }
tr.is-pendiente, .is-pendiente { opacity: .55; }

/* ==========================================================================
   Constancia de radicación (recibo): se ve en pantalla como un documento y se imprime solo ella
   ========================================================================== */
.recibo { max-width: 680px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px 32px 22px; color: var(--text); }
.recibo-cab { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; padding-bottom: 14px; border-bottom: 2px solid var(--text); }
.recibo-entidad { font-weight: 600; font-size: .9375rem; line-height: 1.3; max-width: 46ch; }
.recibo-nit { font-size: .8125rem; color: var(--muted); }
.recibo-tipo { font-size: .8125rem; color: var(--muted); margin-top: 4px; }
.recibo-logo { flex: none; opacity: .9; }
.recibo-numero { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 0 14px; border-bottom: 1px solid var(--rule); }
.recibo .rl { font-size: .75rem; color: var(--muted); }
.recibo .rn { font-size: 1.875rem; font-weight: 500; letter-spacing: -0.01em; line-height: 1.2; }
.recibo .rf { font-size: .8125rem; color: var(--muted); }
.recibo-barras { width: 220px; height: 56px; flex: none; }
.recibo-datos { display: grid; grid-template-columns: 190px 1fr; margin: 0; }
.recibo-datos dt, .recibo-datos dd { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--rule); font-size: .875rem; }
.recibo-datos dt { color: var(--muted); font-weight: 400; }
.recibo-pie { display: flex; gap: 20px; align-items: center; justify-content: space-between; padding-top: 16px; }
.recibo .rc { font-size: 1.375rem; letter-spacing: .12em; }
.recibo-verificacion p { font-size: .75rem; color: var(--muted); margin: 6px 0 0; max-width: 44ch; }
.recibo-url { font-family: var(--mono); font-size: .75rem; word-break: break-all; color: var(--text); }
.recibo-qr { width: 104px; height: 104px; flex: none; }
.recibo-qr svg { width: 100%; height: 100%; display: block; }
.recibo-legal { font-size: .6875rem; color: var(--faint); margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--rule); }
@media (max-width: 575.98px) {
  .recibo { padding: 20px 18px; }
  .recibo-numero { flex-direction: column; align-items: flex-start; }
  .recibo-datos { grid-template-columns: 1fr; }
  .recibo-datos dt { border-bottom: 0; padding-bottom: 0; }
  .recibo .rn { font-size: 1.5rem; }
}

/* Consulta pública (sin sesión) */
.publica { max-width: 760px; margin: 0 auto; padding: 28px 16px 40px; }
.publica-cab { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.publica-entidad { font-size: .8125rem; color: var(--muted); text-align: right; max-width: 40ch; }
.publica-hoja { margin: 0 !important; min-height: 0 !important; border-radius: 16px !important; border: 1px solid var(--border) !important; padding: 28px !important; }
.publica-pie { font-size: .75rem; color: var(--muted); margin-top: 14px; text-align: center; }

/* ==========================================================================
   Impresión: solo la hoja
   ========================================================================== */
@page { margin: 14mm; }
@media print {
  body { background: #fff; }
  .recibo { border: 0; padding: 0; max-width: none; }
  .recibo-cab { border-bottom-color: #000; }
  .app-side, .app-top, .toaster, .no-print, .skip-link, .page-actions { display: none !important; }
  .app-shell { display: block; }
  .app-sheet { border: 0; margin: 0; padding: 0; border-radius: 0; }
  .card { break-inside: avoid; }
}

/* ==========================================================================
   Movimiento reducido: sin desplazamientos, solo cambios de opacidad
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .btn:active:not(:disabled), .btn-icon:active { transform: none; }
  .modal.fade .modal-dialog, .toast-app, .dropdown-menu.show, .ac-panel { transform: none !important; animation: none !important; }
  .toast-app { transition: opacity 160ms ease; }
  .sk { animation: none; }
  tr.is-retirando, .is-retirando { transform: none; }
}
