/* ==========================================================================
   Portal Comunidad — sistema visual de la aplicación (sobre Bootstrap 5.3)
   Paleta original sin cambios: solo se agregan tokens de tipografía, espaciado,
   radios y movimiento, y alias de los neutros que ya se usaban.
   ========================================================================== */
/* Inter 4.1 (variable, SIL Open Font License) servida localmente: ver vendor/fonts/Inter-LICENSE.txt */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/fonts/InterVariable.2bf3d951bf9d.woff2") format("woff2");
}

:root {
  /* --- Paleta (valores originales) --- */
  --pc-bg: #f6f7f9;
  --pc-surface: #ffffff;
  --pc-border: #e6e8ec;
  --pc-border-strong: #d5d9e0;
  --pc-text: #1b1f24;
  --pc-muted: #667085;
  --pc-subtle: #98a2b3;
  --pc-accent: #3b5bdb;
  --pc-accent-hover: #2f4bc2;
  --pc-accent-soft: #edf1fd;
  --pc-success: #12805c;
  --pc-success-soft: #e7f6ef;
  --pc-warning: #a15c07;
  --pc-warning-soft: #fdf3e2;
  --pc-danger: #c4320a;
  --pc-danger-soft: #fdecea;
  /* Neutros que ya existían en la hoja original, ahora con nombre */
  --pc-surface-subtle: #fafbfc;
  --pc-hover: #f2f4f7;
  --pc-fill: #f0f2f5;
  --pc-text-secondary: #475467;
  --pc-nav-text: #3d4451;
  --pc-focus-ring: 0 0 0 3px rgba(59, 91, 219, .18);
  --pc-focus-border: #8aa0ee;

  /* --- Escala tipográfica --- */
  --pc-fs-xs: .75rem;     /* 12 */
  --pc-fs-sm: .8125rem;   /* 13 */
  --pc-fs-base: .875rem;  /* 14 */
  --pc-fs-md: .9375rem;   /* 15 */
  --pc-fs-lg: 1.0625rem;  /* 17 */
  --pc-fs-xl: 1.375rem;   /* 22 */
  --pc-fs-2xl: 1.75rem;   /* 28 */

  /* --- Espaciado (base 4) --- */
  --pc-sp-1: 4px; --pc-sp-2: 8px; --pc-sp-3: 12px; --pc-sp-4: 16px;
  --pc-sp-5: 20px; --pc-sp-6: 24px; --pc-sp-8: 32px; --pc-sp-10: 40px;

  /* --- Forma, profundidad, movimiento --- */
  --pc-sidebar-w: 248px;
  --pc-radius: 10px;
  --pc-radius-sm: 7px;
  --pc-radius-xs: 5px;
  --pc-control-h: 36px;
  --pc-control-h-sm: 30px;
  --pc-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --pc-shadow-md: 0 4px 16px rgba(16, 24, 40, .08);
  --pc-shadow-lg: 0 12px 32px rgba(16, 24, 40, .12), 0 2px 6px rgba(16, 24, 40, .05);
  --pc-ease: cubic-bezier(.2, 0, 0, 1);
  --pc-dur: .14s;

  /* --- Mapeo a Bootstrap --- */
  --bs-body-font-family: "Inter", "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-color: var(--pc-text);
  --bs-body-bg: var(--pc-bg);
  --bs-secondary-color: var(--pc-muted);
  --bs-border-color: var(--pc-border);
  --bs-primary: var(--pc-accent);
  --bs-primary-rgb: 59, 91, 219;
  --bs-success-rgb: 18, 128, 92;
  --bs-warning-rgb: 161, 92, 7;
  --bs-danger-rgb: 196, 50, 10;
  --bs-link-color: var(--pc-accent);
  --bs-link-color-rgb: 59, 91, 219;
  --bs-link-hover-color: var(--pc-accent-hover);
  --bs-link-hover-color-rgb: 47, 75, 194;
  --bs-border-radius: var(--pc-radius-sm);
  --bs-border-radius-lg: var(--pc-radius);
  --bs-focus-ring-color: rgba(59, 91, 219, .25);
}

/* ==========================================================================
   Base
   ========================================================================== */
html, body { height: 100%; }
body {
  font-size: var(--pc-fs-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-optical-sizing: auto;
  background: var(--pc-bg);
  color: var(--pc-text);
}
a { text-decoration: none; transition: color var(--pc-dur) var(--pc-ease); }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
.btn:hover, .nav-link:hover, .list-row:hover, .category-tile:hover, .doc-card a:hover,
.stat-item:hover, .dropdown-item:hover, .cat-bar:hover, .page-link:hover { text-decoration: none; }
h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5, .h6 { font-weight: 600; letter-spacing: -.015em; color: var(--pc-text); }
.text-muted, .text-body-secondary { color: var(--pc-muted) !important; }
.text-subtle { color: var(--pc-subtle) !important; }
.text-success { color: var(--pc-success) !important; }
.text-warning { color: var(--pc-warning) !important; }
.text-danger { color: var(--pc-danger) !important; }
.small, small { font-size: var(--pc-fs-sm); }
.small-caps { font-size: var(--pc-fs-xs); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--pc-subtle); }
.tabular { font-variant-numeric: tabular-nums; }
::selection { background: var(--pc-accent-soft); color: var(--pc-text); }

:focus-visible { outline: 2px solid var(--pc-accent); outline-offset: 2px; }
.btn:focus-visible, .form-control:focus-visible, .form-select:focus-visible, .page-link:focus-visible { outline: 0; }

/* ==========================================================================
   Layout
   ========================================================================== */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  width: var(--pc-sidebar-w);
  flex-shrink: 0;
  background: var(--pc-surface);
  border-right: 1px solid var(--pc-border);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-content {
  padding: var(--pc-sp-8) var(--pc-sp-10) 56px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}
.app-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--pc-sp-2);
  height: 56px;
  padding: 0 var(--pc-sp-3);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--pc-border);
  position: sticky;
  top: 0;
  z-index: 1020;
}
.app-topbar .topbar-title { font-weight: 600; font-size: var(--pc-fs-base); color: var(--pc-text); min-width: 0; }
.app-topbar .topbar-title:hover { text-decoration: none; }
.app-topbar .brand-mark { width: 28px; height: 28px; border-radius: 7px; font-size: .9rem; }

@media (max-width: 1199.98px) {
  .app-content { padding: var(--pc-sp-6) var(--pc-sp-6) 48px; }
}
@media (max-width: 991.98px) {
  .app-sidebar { display: none; }
  .app-topbar { display: flex; }
  .app-content { padding: var(--pc-sp-5) var(--pc-sp-4) 40px; }
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  height: 64px; padding: 0 var(--pc-sp-4);
  border-bottom: 1px solid var(--pc-border);
  color: inherit;
}
.sidebar-brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--pc-accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(16, 24, 40, .08);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.brand-mark.lg { width: 44px; height: 44px; border-radius: 11px; font-size: 1.3rem; }
.brand-text { min-width: 0; }
.brand-title { font-weight: 600; font-size: var(--pc-fs-sm); line-height: 1.3; color: var(--pc-text); }
.brand-sub { font-size: var(--pc-fs-xs); color: var(--pc-muted); line-height: 1.3; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.sidebar-nav { padding: var(--pc-sp-3) var(--pc-sp-2); overflow-y: auto; flex: 1; }
.sidebar-section { margin: var(--pc-sp-5) 10px var(--pc-sp-1); }
.sidebar-nav .nav-link {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 10px; margin-bottom: 1px;
  border-radius: var(--pc-radius-sm);
  color: var(--pc-nav-text); font-weight: 500; font-size: var(--pc-fs-base);
  transition: background-color var(--pc-dur) var(--pc-ease), color var(--pc-dur) var(--pc-ease);
}
.sidebar-nav .nav-link i { font-size: 1rem; color: var(--pc-subtle); width: 18px; text-align: center; transition: color var(--pc-dur) var(--pc-ease); }
.sidebar-nav .nav-link:hover { background: var(--pc-hover); color: var(--pc-text); }
.sidebar-nav .nav-link:hover i { color: var(--pc-muted); }
.sidebar-nav .nav-link.active { background: var(--pc-accent-soft); color: var(--pc-accent); font-weight: 600; }
.sidebar-nav .nav-link.active i { color: var(--pc-accent); }
.sidebar-nav .nav-link.active { box-shadow: inset 0 0 0 1px rgba(59, 91, 219, .1); }

.sidebar-user {
  border-top: 1px solid var(--pc-border);
  padding: var(--pc-sp-3) var(--pc-sp-3) var(--pc-sp-3) var(--pc-sp-4);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--pc-fill); color: var(--pc-text-secondary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--pc-fs-xs); font-weight: 600; flex-shrink: 0; letter-spacing: .02em;
  box-shadow: inset 0 0 0 1px var(--pc-border);
}
.avatar.sm { width: 28px; height: 28px; font-size: .6875rem; }
.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: var(--pc-fs-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.user-role { font-size: var(--pc-fs-xs); color: var(--pc-muted); line-height: 1.3; }

.offcanvas.app-offcanvas { width: var(--pc-sidebar-w); border-right: 1px solid var(--pc-border); }
.offcanvas.app-offcanvas .offcanvas-body { padding: 0; display: flex; flex-direction: column; }

/* ==========================================================================
   Encabezado de página
   ========================================================================== */
.page-header {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: var(--pc-sp-4); margin-bottom: var(--pc-sp-6);
}
.page-header > div:first-child { min-width: 0; }
.page-header h1 { font-size: var(--pc-fs-xl); line-height: 1.25; margin: 0; letter-spacing: -.02em; }
.page-header .lead-text { color: var(--pc-muted); margin: 6px 0 0; font-size: var(--pc-fs-base); max-width: 68ch; }
.page-header .eyebrow { margin-bottom: 6px; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--pc-sp-2); align-items: center; }
.breadcrumb { font-size: var(--pc-fs-sm); margin-bottom: var(--pc-sp-2); --bs-breadcrumb-divider-color: var(--pc-subtle); --bs-breadcrumb-item-padding-x: .45rem; }
.breadcrumb a { color: var(--pc-muted); }
.breadcrumb a:hover { color: var(--pc-text); text-decoration: none; }
.breadcrumb-item.active { color: var(--pc-text); }

.section-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--pc-sp-3);
  margin-bottom: var(--pc-sp-3);
}
.section-title h2 { font-size: var(--pc-fs-md); margin: 0; }
.section-title a { font-size: var(--pc-fs-sm); font-weight: 500; }

/* ==========================================================================
   Tarjetas y superficies
   ========================================================================== */
.card {
  border: 1px solid var(--pc-border);
  border-radius: var(--pc-radius);
  box-shadow: var(--pc-shadow);
  --bs-card-bg: var(--pc-surface);
  --bs-card-border-color: var(--pc-border);
}
.card-header {
  background: transparent; border-bottom: 1px solid var(--pc-border);
  min-height: 52px; padding: var(--pc-sp-3) var(--pc-sp-5); font-weight: 600; font-size: var(--pc-fs-base);
  display: flex; align-items: center; justify-content: space-between; gap: var(--pc-sp-2);
}
.card-header:first-child { border-radius: calc(var(--pc-radius) - 1px) calc(var(--pc-radius) - 1px) 0 0; }
.card-header a, .card-header .card-header-aside { font-size: var(--pc-fs-sm); font-weight: 500; }
.card-header .card-header-aside { color: var(--pc-muted); }
.card-body { padding: var(--pc-sp-5); }
.card-footer { background: var(--pc-surface-subtle); border-top: 1px solid var(--pc-border); padding: var(--pc-sp-3) var(--pc-sp-5); }

/* Franja de indicadores */
.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: hidden; }
.stat-strip.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-strip.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-item {
  display: flex; flex-direction: column; gap: var(--pc-sp-1);
  padding: var(--pc-sp-5); color: inherit; position: relative;
  border-left: 1px solid var(--pc-border);
  transition: background-color var(--pc-dur) var(--pc-ease);
}
.stat-item:first-child { border-left: 0; }
a.stat-item:hover { background: var(--pc-surface-subtle); color: inherit; }
.stat-head { display: flex; align-items: center; gap: var(--pc-sp-2); color: var(--pc-muted); font-size: var(--pc-fs-sm); font-weight: 500; }
.stat-head i { font-size: .95rem; color: var(--pc-subtle); }
.stat-item .stat-value { font-size: var(--pc-fs-2xl); font-weight: 600; letter-spacing: -.025em; line-height: 1.15; margin-top: var(--pc-sp-1); font-variant-numeric: tabular-nums; }
.stat-item .stat-foot { font-size: var(--pc-fs-xs); color: var(--pc-muted); }
.stat-item .stat-go { position: absolute; top: var(--pc-sp-5); right: var(--pc-sp-4); color: var(--pc-subtle); opacity: 0; transform: translateX(-3px); transition: opacity var(--pc-dur) var(--pc-ease), transform var(--pc-dur) var(--pc-ease); }
a.stat-item:hover .stat-go { opacity: 1; transform: none; }
.stat-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pc-subtle); display: inline-block; }
.stat-dot.accent { background: var(--pc-accent); }
.stat-dot.success { background: var(--pc-success); }
.stat-dot.warning { background: var(--pc-warning); }

@media (max-width: 991.98px) {
  .stat-strip, .stat-strip.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-item:nth-child(odd) { border-left: 0; }
  .stat-item:nth-child(n+3) { border-top: 1px solid var(--pc-border); }
  .stat-strip.cols-3 .stat-item:last-child { grid-column: span 2; }
}

/* Compatibilidad: tarjeta de indicador individual */
.stat-card { padding: var(--pc-sp-5); height: 100%; }
.stat-value { font-size: var(--pc-fs-2xl); font-weight: 600; letter-spacing: -.025em; line-height: 1.15; }
.stat-label { color: var(--pc-muted); font-size: var(--pc-fs-sm); margin-top: 2px; }

/* ==========================================================================
   Listas
   ========================================================================== */
.list-row {
  display: flex; align-items: center; gap: var(--pc-sp-3);
  min-height: 60px; padding: 10px var(--pc-sp-5);
  border-bottom: 1px solid var(--pc-border); color: inherit;
  transition: background-color var(--pc-dur) var(--pc-ease);
}
.list-row:last-child { border-bottom: 0; }
a.list-row:hover, .list-row.is-link:hover { background: var(--pc-surface-subtle); color: inherit; }
.list-row .row-main { flex: 1; min-width: 0; color: inherit; }
.list-row .row-main:hover { text-decoration: none; }
.list-row .row-title { font-weight: 500; font-size: var(--pc-fs-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--pc-text); }
.list-row a.row-main:hover .row-title, a.list-row:hover .row-title { color: var(--pc-accent); }
.list-row .row-meta { font-size: var(--pc-fs-xs); color: var(--pc-muted); }
.list-row .row-aside { font-size: var(--pc-fs-xs); color: var(--pc-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.list-row.compact { min-height: 52px; }

.file-icon {
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--pc-hover); color: var(--pc-text-secondary); font-size: 1rem;
}
.file-icon.pdf { background: #fdecea; color: #c4320a; }
.file-icon.word { background: #eaf1fd; color: #2251c5; }
.file-icon.excel { background: #e7f6ef; color: #12805c; }
.file-icon.image { background: #f4ecfd; color: #7a3fc4; }
.file-icon.danger { background: var(--pc-danger-soft); color: var(--pc-danger); }
.file-icon.accent { background: var(--pc-accent-soft); color: var(--pc-accent); }

/* Estado vacío */
.empty-state { text-align: center; padding: 48px var(--pc-sp-5); color: var(--pc-muted); font-size: var(--pc-fs-base); }
.empty-state > i {
  width: 44px; height: 44px; border-radius: 12px; margin: 0 auto var(--pc-sp-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; color: var(--pc-muted); background: var(--pc-hover);
}
.empty-state .empty-title { display: block; color: var(--pc-text); font-weight: 600; font-size: var(--pc-fs-md); margin-bottom: 2px; }
.empty-state.sm { padding: 28px var(--pc-sp-5); }
.empty-state.sm > i { width: 36px; height: 36px; font-size: 1.05rem; border-radius: 10px; margin-bottom: var(--pc-sp-2); }

/* Barras de categoría */
.cat-bar { padding: 9px var(--pc-sp-5); display: block; color: inherit; transition: background-color var(--pc-dur) var(--pc-ease); }
.cat-bar:hover { background: var(--pc-surface-subtle); color: inherit; }
.cat-bar .cat-bar-head { display: flex; justify-content: space-between; align-items: center; gap: var(--pc-sp-2); font-size: var(--pc-fs-sm); }
.cat-bar .cat-bar-head i { color: var(--pc-subtle); margin-right: var(--pc-sp-2); }
.cat-bar .cat-bar-count { font-weight: 600; font-variant-numeric: tabular-nums; }
.cat-bar.is-empty .cat-bar-count, .cat-bar.is-empty .cat-bar-name { color: var(--pc-subtle); }
.cat-bar .track { height: 4px; background: var(--pc-fill); border-radius: 4px; margin-top: 7px; overflow: hidden; }
.cat-bar .fill { height: 100%; width: 0; background: var(--pc-accent); border-radius: 4px; transition: width .5s var(--pc-ease); }

/* Accesos rápidos */
.category-tile {
  display: flex; align-items: center; gap: var(--pc-sp-3);
  padding: var(--pc-sp-3) 14px; border: 1px solid var(--pc-border); border-radius: var(--pc-radius);
  background: var(--pc-surface); color: inherit; height: 100%;
  box-shadow: var(--pc-shadow);
  transition: border-color var(--pc-dur) var(--pc-ease), box-shadow var(--pc-dur) var(--pc-ease), transform var(--pc-dur) var(--pc-ease);
}
.category-tile:hover { border-color: var(--pc-border-strong); box-shadow: var(--pc-shadow-md); color: inherit; transform: translateY(-1px); }
.category-tile .cat-icon {
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--pc-accent-soft); color: var(--pc-accent); font-size: 1rem;
}
.category-tile .cat-name { font-weight: 600; font-size: var(--pc-fs-sm); line-height: 1.3; }
.category-tile .cat-count { font-size: var(--pc-fs-xs); color: var(--pc-muted); font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Tablas
   ========================================================================== */
.table-card { overflow: hidden; }
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--pc-sp-3);
  min-height: 48px; padding: var(--pc-sp-2) var(--pc-sp-5);
  border-bottom: 1px solid var(--pc-border); font-size: var(--pc-fs-sm); color: var(--pc-muted);
}
.table-toolbar strong { color: var(--pc-text); font-weight: 600; font-variant-numeric: tabular-nums; }
.table { margin: 0; --bs-table-bg: transparent; --bs-table-color: var(--pc-text); font-size: var(--pc-fs-base); }
.table thead th {
  font-size: var(--pc-fs-xs); font-weight: 500; color: var(--pc-muted);
  background: var(--pc-surface-subtle);
  border-bottom: 1px solid var(--pc-border); padding: 10px var(--pc-sp-4); white-space: nowrap;
}
.table thead th:first-child, .table td:first-child { padding-left: var(--pc-sp-5); }
.table thead th:last-child, .table td:last-child { padding-right: var(--pc-sp-5); }
.table td { padding: var(--pc-sp-3) var(--pc-sp-4); vertical-align: middle; border-color: var(--pc-border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover > tbody > tr { transition: background-color var(--pc-dur) var(--pc-ease); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--pc-surface-subtle); --bs-table-hover-bg: var(--pc-surface-subtle); }
.table .cell-muted { color: var(--pc-muted); }
.table .cell-num { font-variant-numeric: tabular-nums; }
.doc-title-link { font-weight: 500; color: var(--pc-text); display: inline-block; max-width: 100%; }
.doc-title-link:hover { color: var(--pc-accent); text-decoration: none; }
.table-compact { font-size: var(--pc-fs-sm); }
.table-compact td { padding-top: 7px; padding-bottom: 7px; }
.table-compact thead th { padding-top: 8px; padding-bottom: 8px; }
.table-compact .cell-doc { max-width: 0; width: 46%; }
.table-compact .doc-title-link { flex: 0 1 auto; min-width: 0; }
.table-compact .badge-soft { height: 20px; font-size: .6875rem; padding: 0 7px; flex-shrink: 0; }
.file-icon.sm { width: 26px; height: 26px; border-radius: 6px; font-size: .85rem; }
.doc-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 3px; font-size: var(--pc-fs-xs); color: var(--pc-muted); }

/* Acciones por fila: discretas, más visibles al pasar el cursor */
.row-actions { display: inline-flex; align-items: center; gap: var(--pc-sp-1); justify-content: flex-end; }
@media (hover: hover) {
  .table-hover tbody tr .row-actions .btn-ghost { opacity: .7; }
  .table-hover tbody tr:hover .row-actions .btn-ghost,
  .table-hover tbody tr .row-actions .btn-ghost:focus-visible { opacity: 1; }
}

/* Tarjetas de documentos (mobile) */
.doc-card { display: flex; align-items: center; gap: var(--pc-sp-3); padding: 10px var(--pc-sp-2) 10px var(--pc-sp-4); border-bottom: 1px solid var(--pc-border); }
.doc-card:last-child { border-bottom: 0; }
.doc-card .doc-card-title { font-weight: 500; font-size: var(--pc-fs-base); color: var(--pc-text); line-height: 1.35; }
.doc-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 2px; font-size: var(--pc-fs-xs); color: var(--pc-muted); }
.doc-card-meta .badge-soft { height: 18px; font-size: .65rem; padding: 0 6px; }

/* Celdas que ceden ancho y recortan su contenido */
.cell-fluid { max-width: 0; width: 100%; }

/* Actividad en celular */
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-item { padding: 10px var(--pc-sp-4); border-bottom: 1px solid var(--pc-border); font-size: var(--pc-fs-sm); }
.activity-item:last-child { border-bottom: 0; }
.activity-time { font-size: var(--pc-fs-xs); color: var(--pc-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.activity-meta { font-size: var(--pc-fs-xs); color: var(--pc-text-secondary); overflow-wrap: anywhere; }

/* Filtros plegables en celular */
.filter-more { display: contents; }
.filter-toggle { position: relative; flex-shrink: 0; }
.filter-dot { display: none; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--pc-accent); box-shadow: 0 0 0 2px var(--pc-surface); }
.filter-bar.has-active .filter-dot { display: block; }
.filter-bar.is-open .filter-toggle { background: var(--pc-accent-soft); border-color: rgba(59, 91, 219, .3); color: var(--pc-accent); }
@media (max-width: 767.98px) {
  .filter-more { display: none; }
  .filter-bar.is-open .filter-more { display: contents; }
}

/* ==========================================================================
   Badges
   ========================================================================== */
.badge-soft {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; font-size: var(--pc-fs-xs); font-weight: 500; line-height: 1; padding: 0 8px; border-radius: 999px;
  background: var(--pc-fill); color: var(--pc-text-secondary); white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(16, 24, 40, .04);
}
.badge-soft::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; flex-shrink: 0; }
.badge-soft.no-dot::before { display: none; }
.badge-soft.success { background: var(--pc-success-soft); color: var(--pc-success); }
.badge-soft.warning { background: var(--pc-warning-soft); color: var(--pc-warning); }
.badge-soft.danger { background: var(--pc-danger-soft); color: var(--pc-danger); }
.badge-soft.accent { background: var(--pc-accent-soft); color: var(--pc-accent); }
.badge-soft i { font-size: .75rem; }
.badge-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--pc-fill); color: var(--pc-text-secondary);
  font-size: .6875rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.sidebar-nav .nav-link .badge-count { margin-left: auto; }

/* ==========================================================================
   Botones
   ========================================================================== */
.btn {
  --bs-btn-font-weight: 500;
  --bs-btn-font-size: var(--pc-fs-base);
  --bs-btn-padding-x: .875rem;
  --bs-btn-padding-y: 0;
  --bs-btn-border-radius: var(--pc-radius-sm);
  --bs-btn-focus-box-shadow: var(--pc-focus-ring);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--pc-control-h); line-height: 1.2; white-space: nowrap;
  transition: color var(--pc-dur) var(--pc-ease), background-color var(--pc-dur) var(--pc-ease),
              border-color var(--pc-dur) var(--pc-ease), box-shadow var(--pc-dur) var(--pc-ease), opacity var(--pc-dur) var(--pc-ease);
}
.btn i { font-size: 1em; line-height: 1; }
.btn .me-1, .btn .me-2 { margin-right: 0 !important; }
.btn:active { transform: translateY(.5px); }
.btn-sm { --bs-btn-font-size: var(--pc-fs-sm); --bs-btn-padding-x: .625rem; min-height: var(--pc-control-h-sm); gap: 5px; }
.btn-lg { min-height: 42px; --bs-btn-font-size: var(--pc-fs-md); }
.btn-primary {
  --bs-btn-color: #fff; --bs-btn-bg: var(--pc-accent); --bs-btn-border-color: var(--pc-accent);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--pc-accent-hover); --bs-btn-hover-border-color: var(--pc-accent-hover);
  --bs-btn-active-color: #fff; --bs-btn-active-bg: var(--pc-accent-hover); --bs-btn-active-border-color: var(--pc-accent-hover);
  --bs-btn-disabled-bg: var(--pc-accent); --bs-btn-disabled-border-color: var(--pc-accent);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.btn-light {
  --bs-btn-color: var(--pc-text); --bs-btn-bg: var(--pc-surface); --bs-btn-border-color: var(--pc-border-strong);
  --bs-btn-hover-color: var(--pc-text); --bs-btn-hover-bg: var(--pc-bg); --bs-btn-hover-border-color: var(--pc-border-strong);
  --bs-btn-active-color: var(--pc-text); --bs-btn-active-bg: var(--pc-hover); --bs-btn-active-border-color: var(--pc-border-strong);
  --bs-btn-disabled-color: var(--pc-muted); --bs-btn-disabled-bg: var(--pc-surface); --bs-btn-disabled-border-color: var(--pc-border);
  box-shadow: var(--pc-shadow);
}
.btn-danger {
  --bs-btn-color: #fff; --bs-btn-bg: var(--pc-danger); --bs-btn-border-color: var(--pc-danger);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--pc-danger); --bs-btn-hover-border-color: var(--pc-danger);
  --bs-btn-active-bg: var(--pc-danger); --bs-btn-active-border-color: var(--pc-danger);
  --bs-btn-disabled-bg: var(--pc-danger); --bs-btn-disabled-border-color: var(--pc-danger);
  --bs-btn-focus-box-shadow: 0 0 0 3px rgba(196, 50, 10, .2);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}
.btn-danger:hover, .btn-danger:active { filter: brightness(.92); }
.btn-ghost {
  --bs-btn-color: var(--pc-muted); --bs-btn-bg: transparent; --bs-btn-border-color: transparent;
  --bs-btn-hover-color: var(--pc-text); --bs-btn-hover-bg: var(--pc-hover); --bs-btn-hover-border-color: transparent;
  --bs-btn-active-color: var(--pc-text); --bs-btn-active-bg: var(--pc-fill); --bs-btn-active-border-color: transparent;
}
.btn-ghost.text-danger:hover { background: var(--pc-danger-soft); }
.btn-icon { --bs-btn-padding-x: 0; width: var(--pc-control-h); padding: 0; }
.btn-sm.btn-icon { width: var(--pc-control-h-sm); }
.btn-close { --bs-btn-close-focus-shadow: var(--pc-focus-ring); width: .75em; height: .75em; }

/* Estado de carga (formularios con data-once) */
.btn.is-loading { pointer-events: none; opacity: .85; }
.btn.is-loading::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: pc-spin .7s linear infinite; flex-shrink: 0;
}
.btn.is-loading i { display: none; }
@keyframes pc-spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Formularios
   ========================================================================== */
.form-label { font-weight: 500; font-size: var(--pc-fs-sm); margin-bottom: 6px; color: var(--pc-text); }
.form-control, .form-select {
  min-height: var(--pc-control-h);
  background-color: var(--pc-surface);
  border-color: var(--pc-border-strong);
  border-radius: var(--pc-radius-sm);
  font-size: var(--pc-fs-base); color: var(--pc-text);
  padding: .4375rem .75rem;
  box-shadow: 0 1px 1px rgba(16, 24, 40, .03);
  transition: border-color var(--pc-dur) var(--pc-ease), box-shadow var(--pc-dur) var(--pc-ease), background-color var(--pc-dur) var(--pc-ease);
}
.form-select { padding-right: 2.25rem; background-position: right .7rem center; }
.form-control:hover:not(:disabled):not(:focus), .form-select:hover:not(:disabled):not(:focus) { border-color: #c4c9d2; }
.form-control::placeholder { color: var(--pc-subtle); opacity: 1; }
.form-control:focus, .form-select:focus { border-color: var(--pc-focus-border); box-shadow: var(--pc-focus-ring); background-color: var(--pc-surface); }
.form-control:disabled, .form-select:disabled, .form-control[readonly] { background-color: var(--pc-bg); color: var(--pc-muted); box-shadow: none; }
textarea.form-control { min-height: 96px; line-height: 1.5; }
.form-control-sm, .form-select-sm { min-height: var(--pc-control-h-sm); font-size: var(--pc-fs-sm); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--pc-danger); background-image: none; padding-right: .75rem; }
.form-select.is-invalid { padding-right: 2.25rem; background-image: var(--bs-form-select-bg-img); }
.form-control.is-invalid:focus, .form-select.is-invalid:focus { border-color: var(--pc-danger); box-shadow: 0 0 0 3px rgba(196, 50, 10, .15); }
.form-control[type=file] { padding: 0; overflow: hidden; line-height: var(--pc-control-h); }
.form-control[type=file]::file-selector-button {
  height: calc(var(--pc-control-h) - 2px); margin: 0 .75rem 0 0; padding: 0 .875rem;
  border: 0; border-right: 1px solid var(--pc-border-strong); border-radius: 0;
  background: var(--pc-surface-subtle); color: var(--pc-text); font-weight: 500; font-size: var(--pc-fs-sm);
}
.form-control[type=file]:hover:not(:disabled)::file-selector-button { background: var(--pc-hover); }
.form-check { min-height: 1.5rem; }
.form-check-input { border-color: var(--pc-border-strong); margin-top: .2em; }
.form-check-input:focus { border-color: var(--pc-focus-border); box-shadow: var(--pc-focus-ring); }
.form-check-input:checked { background-color: var(--pc-accent); border-color: var(--pc-accent); }
.form-check-label { font-size: var(--pc-fs-base); }
.form-text { color: var(--pc-muted); font-size: var(--pc-fs-xs); margin-top: 6px; }
.invalid-feedback { font-size: var(--pc-fs-xs); color: var(--pc-danger); margin-top: 6px; }
.required-mark { color: var(--pc-danger); margin-left: 2px; }

/* Secciones: título a la izquierda y campos a la derecha en pantallas anchas */
.form-section { padding: var(--pc-sp-6); border-bottom: 1px solid var(--pc-border); }
.form-section:last-of-type { border-bottom: 0; }
.form-section-title { font-size: var(--pc-fs-md); font-weight: 600; margin-bottom: 2px; }
.form-section-desc { font-size: var(--pc-fs-sm); color: var(--pc-muted); margin-bottom: var(--pc-sp-4); line-height: 1.5; }
@media (min-width: 1200px) {
  .form-split .form-section:has(> .form-section-head) { display: grid; grid-template-columns: 232px minmax(0, 1fr); column-gap: var(--pc-sp-8); }
  .form-split .form-section-head .form-section-desc { margin-bottom: 0; }
  .form-split .form-section > .form-section-full { grid-column: 1 / -1; }
}
.form-actions {
  display: flex; flex-wrap: wrap; gap: var(--pc-sp-2); justify-content: flex-end; align-items: center;
  padding: var(--pc-sp-4) var(--pc-sp-6); background: var(--pc-surface-subtle); border-top: 1px solid var(--pc-border);
  border-radius: 0 0 var(--pc-radius) var(--pc-radius);
}
.form-actions .form-actions-note { margin-right: auto; font-size: var(--pc-fs-xs); color: var(--pc-muted); }

/* Opciones tipo tarjeta (radio) */
.choice-group { display: grid; gap: var(--pc-sp-2); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.choice-card { position: relative; margin: 0; }
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-card .choice-body {
  display: flex; gap: 10px; align-items: flex-start;
  padding: var(--pc-sp-3) 14px; border: 1px solid var(--pc-border-strong); border-radius: var(--pc-radius-sm);
  cursor: pointer; background: var(--pc-surface); height: 100%; font-size: var(--pc-fs-sm);
  transition: border-color var(--pc-dur) var(--pc-ease), background-color var(--pc-dur) var(--pc-ease), box-shadow var(--pc-dur) var(--pc-ease);
}
.choice-card .choice-body:hover { border-color: #c4c9d2; background: var(--pc-surface-subtle); }
.choice-card .choice-body i { font-size: 1rem; color: var(--pc-subtle); margin-top: 1px; }
.choice-card input:checked + .choice-body { border-color: var(--pc-accent); background: var(--pc-accent-soft); box-shadow: inset 0 0 0 1px var(--pc-accent); }
.choice-card input:checked + .choice-body i { color: var(--pc-accent); }
.choice-card input:focus-visible + .choice-body { box-shadow: var(--pc-focus-ring); }
.choice-title { font-weight: 600; display: block; color: var(--pc-text); font-size: var(--pc-fs-base); }
.choice-desc { color: var(--pc-muted); font-size: var(--pc-fs-xs); }

/* Selector de iconos */
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.icon-grid .choice-body { justify-content: center; align-items: center; padding: 10px 0; }
.icon-grid .choice-body i { margin: 0; font-size: 1.1rem; }

/* Zona de archivo */
.file-drop {
  border: 1.5px dashed var(--pc-border-strong); border-radius: var(--pc-radius);
  padding: var(--pc-sp-5); background: var(--pc-surface-subtle);
  transition: border-color var(--pc-dur) var(--pc-ease), background-color var(--pc-dur) var(--pc-ease);
}
.file-drop:hover, .file-drop:focus-within { border-color: var(--pc-focus-border); background: var(--pc-surface); }
.file-drop.is-invalid { border-color: var(--pc-danger); }
.file-drop .file-info { font-size: var(--pc-fs-sm); margin-top: var(--pc-sp-2); font-variant-numeric: tabular-nums; }
.file-current {
  display: flex; align-items: center; gap: var(--pc-sp-3); padding: 10px var(--pc-sp-3);
  border: 1px solid var(--pc-border); border-radius: var(--pc-radius-sm); background: var(--pc-surface); margin-bottom: var(--pc-sp-3);
}

/* Filtros */
.filter-bar { padding: var(--pc-sp-3); }
.filter-bar .row { --bs-gutter-x: .5rem; --bs-gutter-y: .5rem; }
.filter-bar .form-label { font-size: var(--pc-fs-xs); color: var(--pc-muted); margin-bottom: 4px; }
.search-input { position: relative; }
.search-input i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--pc-subtle); pointer-events: none; font-size: .9rem; }
.search-input .form-control { padding-left: 34px; }
.filter-actions { display: flex; gap: var(--pc-sp-2); justify-content: flex-end; align-items: flex-end; }

/* ==========================================================================
   Detalle de documento
   ========================================================================== */
.meta-list { margin: 0; }
.meta-list dt { font-size: var(--pc-fs-xs); font-weight: 500; color: var(--pc-muted); margin-bottom: 2px; }
.meta-list dd { margin-bottom: var(--pc-sp-4); font-size: var(--pc-fs-base); }
.meta-list dd:last-child { margin-bottom: 0; }
.meta-rows { margin: 0; }
.meta-rows > div { display: flex; justify-content: space-between; gap: var(--pc-sp-4); padding: 11px var(--pc-sp-5); border-bottom: 1px solid var(--pc-border); font-size: var(--pc-fs-sm); }
.meta-rows > div:last-child { border-bottom: 0; }
.meta-rows dt { font-weight: 400; color: var(--pc-muted); flex-shrink: 0; }
.meta-rows dd { margin: 0; text-align: right; font-weight: 500; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.doc-hero { display: flex; gap: var(--pc-sp-4); align-items: flex-start; min-width: 0; }
.doc-hero .file-icon { width: 48px; height: 48px; font-size: 1.4rem; border-radius: 11px; }
.doc-hero h1 { overflow-wrap: anywhere; }
.prewrap { white-space: pre-line; }
.note-internal { background: var(--pc-warning-soft); border-top: 1px solid var(--pc-border); }
.note-internal .small-caps { color: var(--pc-warning); }

/* Detalle con vista previa a la derecha */
.doc-layout { display: grid; gap: var(--pc-sp-6); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1200px) {
  .doc-layout { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); }
  .doc-preview { position: sticky; top: var(--pc-sp-6); }
}
.doc-preview { overflow: hidden; display: flex; flex-direction: column; }
.doc-preview .card-header { gap: var(--pc-sp-3); }
.doc-preview .card-header > .text-truncate { min-width: 0; font-weight: 500; font-size: var(--pc-fs-sm); }
.doc-preview-frame { display: block; width: 100%; height: min(78vh, 1000px); min-height: 420px; border: 0; background: var(--pc-hover); }
.doc-preview-empty { min-height: 320px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
@media (max-width: 575.98px) { .doc-preview-frame { height: 70vh; min-height: 360px; } }

.file-list { list-style: none; margin: 0; padding: 0; }
.file-list.bordered { border: 1px solid var(--pc-border); border-radius: var(--pc-radius-sm); }
.file-item { display: flex; align-items: center; gap: var(--pc-sp-3); padding: 10px var(--pc-sp-4); border-bottom: 1px solid var(--pc-border); transition: background-color var(--pc-dur) var(--pc-ease); }
.file-item:last-child { border-bottom: 0; }
.file-item:hover { background: var(--pc-surface-subtle); }
.file-item.is-selected { background: var(--pc-accent-soft); }
.file-item .file-icon { width: 30px; height: 30px; font-size: .9rem; border-radius: 7px; }
.file-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; color: inherit; }
.file-item-main:hover { text-decoration: none; }
.file-item-name { font-size: var(--pc-fs-sm); font-weight: 500; color: var(--pc-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.file-item-main:hover .file-item-name, .file-item.is-selected .file-item-name { color: var(--pc-accent); }
.file-item-meta { font-size: var(--pc-fs-xs); color: var(--pc-muted); }

/* Selector segmentado */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--pc-fill); border-radius: var(--pc-radius-sm); }
.segmented-item { padding: 5px 12px; border-radius: var(--pc-radius-xs); font-size: var(--pc-fs-sm); font-weight: 500; color: var(--pc-muted); white-space: nowrap; }
.segmented-item:hover { color: var(--pc-text); text-decoration: none; }
.segmented-item.is-active { background: var(--pc-surface); color: var(--pc-text); box-shadow: var(--pc-shadow); }
@media (max-width: 575.98px) { .segmented { width: 100%; } .segmented-item { flex: 1; text-align: center; padding: 5px 6px; } }

/* Gráficos (SVG generado en el servidor) */
.chart-wrap { position: relative; }
.chart { display: block; width: 100%; height: auto; overflow: visible; font-family: inherit; }
.chart-grid { stroke: var(--pc-border); stroke-width: 1; shape-rendering: crispEdges; }
.chart-axis { stroke: var(--pc-border-strong); stroke-width: 1; shape-rendering: crispEdges; }
.chart-tick { fill: var(--pc-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-tick.is-major { fill: var(--pc-text-secondary); font-weight: 500; }
.chart-year-line { stroke: var(--pc-subtle); stroke-width: 1; stroke-dasharray: 4 4; shape-rendering: crispEdges; }
.chart-year { fill: var(--pc-text-secondary); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-value { fill: var(--pc-text); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-col { fill: var(--pc-accent); transition: opacity var(--pc-dur) var(--pc-ease); }
.chart-hit { fill: transparent; }
.chart-bar { cursor: pointer; outline: none; }
.chart-wrap:hover .chart-col, .chart-wrap:focus-within .chart-col { opacity: .45; }
.chart-wrap .chart-bar:hover .chart-col, .chart-wrap .chart-bar:focus .chart-col { opacity: 1; }
.chart-bar:focus-visible .chart-hit { fill: var(--pc-accent-soft); }
.chart-tooltip {
  position: absolute; z-index: 5; pointer-events: none; transform: translate(-50%, calc(-100% - 10px));
  background: var(--pc-text); color: #fff; border-radius: var(--pc-radius-xs); padding: 6px 10px;
  font-size: var(--pc-fs-xs); line-height: 1.35; white-space: nowrap; box-shadow: var(--pc-shadow-md);
}
.chart-tooltip strong { display: block; font-size: var(--pc-fs-sm); font-variant-numeric: tabular-nums; }
.chart-tooltip span { color: rgba(255, 255, 255, .75); text-transform: capitalize; }
.chart-bar.is-active .chart-col { opacity: 1; }
.chart-wrap.has-active .chart-col { opacity: .45; }
.chart-wrap.has-active .chart-bar.is-active .chart-col { opacity: 1; }

/* Gráfico apilado: paleta categórica validada (orden fijo, nunca rotada). */
:root {
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  --series-4: #eda100; --series-5: #e87ba4; --series-6: #008300;
}
.chart-col.is-ghost { fill: transparent; }
/* Hito en el gráfico (distinto de los separadores de año: color y trazo propios). */
.chart-marker-group { pointer-events: none; }
.chart-marker { stroke: var(--pc-warning); stroke-width: 1.5; stroke-dasharray: 2 3; }
.chart-marker-label { fill: var(--pc-warning); font-size: 11px; font-weight: 600; paint-order: stroke; stroke: var(--pc-surface); stroke-width: 4px; stroke-linejoin: round; }
.chart-seg { transition: opacity var(--pc-dur) var(--pc-ease); }
.s-1 { fill: var(--series-1); } .s-2 { fill: var(--series-2); } .s-3 { fill: var(--series-3); }
.s-4 { fill: var(--series-4); } .s-5 { fill: var(--series-5); } .s-6 { fill: var(--series-6); }
.chart-wrap:hover .chart-seg, .chart-wrap:focus-within .chart-seg, .chart-wrap.has-active .chart-seg { opacity: .4; }
.chart-wrap .chart-bar:hover .chart-seg, .chart-wrap .chart-bar:focus .chart-seg,
.chart-wrap.has-active .chart-bar.is-active .chart-seg { opacity: 1; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch.s-1 { background: var(--series-1); } .swatch.s-2 { background: var(--series-2); } .swatch.s-3 { background: var(--series-3); }
.swatch.s-4 { background: var(--series-4); } .swatch.s-5 { background: var(--series-5); } .swatch.s-6 { background: var(--series-6); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 var(--pc-sp-3); padding: 0; list-style: none; font-size: var(--pc-fs-xs); color: var(--pc-text-secondary); }
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.chart-tooltip .tip-rows { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 8px; margin-top: 6px; align-items: center; }
.chart-tooltip .tip-rows span { text-transform: none; }
.chart-tooltip .tip-rows b { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* Composición del gasto (barras horizontales) */
.mix-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; padding: var(--pc-sp-3) var(--pc-sp-5); border-top: 1px solid var(--pc-border); }
.mix-row:first-child { border-top: 0; }
.mix-name { display: flex; align-items: center; gap: 8px; font-size: var(--pc-fs-sm); font-weight: 500; color: var(--pc-text); min-width: 0; }
.mix-sub { font-size: var(--pc-fs-xs); color: var(--pc-muted); font-weight: 400; }
.mix-value { text-align: right; font-size: var(--pc-fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mix-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--pc-fill); overflow: hidden; }
.mix-bar > span { display: block; height: 100%; width: 0; border-radius: 3px; transition: width .5s var(--pc-ease); }
.mix-bar > span.s-1 { background: var(--series-1); } .mix-bar > span.s-2 { background: var(--series-2); } .mix-bar > span.s-3 { background: var(--series-3); }
.mix-bar > span.s-4 { background: var(--series-4); } .mix-bar > span.s-5 { background: var(--series-5); } .mix-bar > span.s-6 { background: var(--series-6); }
.mix-delta { font-size: var(--pc-fs-xs); color: var(--pc-muted); font-weight: 500; white-space: nowrap; text-align: right; }
.mix-delta.is-up { color: var(--pc-danger); }
.mix-delta.is-down { color: var(--pc-success); }

/* Sugerencia al elegir el PDF de un informe */
.file-hint { margin-top: var(--pc-sp-2); padding: 8px 12px; border-radius: var(--pc-radius-xs); background: var(--pc-accent-soft); color: var(--pc-text); font-size: var(--pc-fs-sm); line-height: 1.45; }
.file-hint.is-warning { background: var(--pc-warning-soft); color: var(--pc-warning); }

/* Resultado de búsqueda dentro del contenido */
.search-hit { display: block; margin-top: 2px; font-size: var(--pc-fs-xs); color: var(--pc-muted); line-height: 1.45; white-space: normal; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.table-compact .cell-doc .search-hit { margin-left: 32px; }
.search-hit mark { padding: 0 1px; background: #fff3bf; color: var(--pc-text); border-radius: 2px; }
.data-table { border-top: 1px solid var(--pc-border); }
.data-table > summary { padding: var(--pc-sp-3) var(--pc-sp-5); font-size: var(--pc-fs-sm); font-weight: 500; color: var(--pc-accent); cursor: pointer; list-style: none; }
.data-table > summary::-webkit-details-marker { display: none; }
.data-table > summary::before { content: "\203A"; display: inline-block; margin-right: 8px; transition: transform var(--pc-dur) var(--pc-ease); }
.data-table[open] > summary::before { transform: rotate(90deg); }
.data-table[open] > summary { border-bottom: 1px solid var(--pc-border); }
.border-bottom { border-bottom: 1px solid var(--pc-border) !important; }

/* ==========================================================================
   Paginación
   ========================================================================== */
.pagination {
  --bs-pagination-color: var(--pc-text); --bs-pagination-bg: var(--pc-surface);
  --bs-pagination-hover-color: var(--pc-text); --bs-pagination-hover-bg: var(--pc-hover); --bs-pagination-hover-border-color: var(--pc-border-strong);
  --bs-pagination-focus-box-shadow: var(--pc-focus-ring); --bs-pagination-focus-bg: var(--pc-hover);
  --bs-pagination-active-bg: var(--pc-accent); --bs-pagination-active-border-color: var(--pc-accent);
  --bs-pagination-disabled-color: var(--pc-subtle); --bs-pagination-disabled-bg: var(--pc-surface);
  --bs-pagination-border-color: var(--pc-border-strong); --bs-pagination-font-size: var(--pc-fs-sm);
  --bs-pagination-padding-x: .625rem; --bs-pagination-padding-y: 0;
  margin: 0; gap: 4px;
}
.pagination .page-link { min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--pc-radius-sm) !important; font-variant-numeric: tabular-nums; margin-left: 0 !important; }
.pagination .page-item.active .page-link { background: var(--pc-surface); color: var(--pc-text); border-color: var(--pc-border-strong); font-weight: 500; }

/* ==========================================================================
   Alertas y mensajes
   ========================================================================== */
.alert {
  --bs-alert-padding-x: var(--pc-sp-4); --bs-alert-padding-y: var(--pc-sp-3);
  border-radius: var(--pc-radius-sm); font-size: var(--pc-fs-base); border-width: 1px; line-height: 1.5;
}
.alert > i { font-size: 1rem; line-height: 1.5; margin-top: 0 !important; }
.alert-success { --bs-alert-bg: var(--pc-success-soft); --bs-alert-color: var(--pc-text); --bs-alert-border-color: rgba(18, 128, 92, .22); --bs-alert-link-color: var(--pc-success); }
.alert-success > i { color: var(--pc-success); }
.alert-warning { --bs-alert-bg: var(--pc-warning-soft); --bs-alert-color: var(--pc-text); --bs-alert-border-color: rgba(161, 92, 7, .22); --bs-alert-link-color: var(--pc-warning); }
.alert-warning > i { color: var(--pc-warning); }
.alert-danger { --bs-alert-bg: var(--pc-danger-soft); --bs-alert-color: var(--pc-text); --bs-alert-border-color: rgba(196, 50, 10, .22); --bs-alert-link-color: var(--pc-danger); }
.alert-danger > i { color: var(--pc-danger); }
.alert-info { --bs-alert-bg: var(--pc-accent-soft); --bs-alert-color: var(--pc-text); --bs-alert-border-color: rgba(59, 91, 219, .22); --bs-alert-link-color: var(--pc-accent); }
.alert-info > i { color: var(--pc-accent); }
.alert-light { --bs-alert-bg: var(--pc-surface-subtle); --bs-alert-color: var(--pc-text-secondary); --bs-alert-border-color: var(--pc-border); }
.alert-dismissible { padding-right: 3rem; }
.alert-dismissible .btn-close { padding: 1.05rem 1rem; }
.messages-stack { display: grid; gap: var(--pc-sp-2); }
.messages-stack .alert { margin: 0; box-shadow: var(--pc-shadow); }

/* ==========================================================================
   Menús, modales, offcanvas, tooltips
   ========================================================================== */
.dropdown-menu {
  --bs-dropdown-border-color: var(--pc-border); --bs-dropdown-border-radius: var(--pc-radius);
  --bs-dropdown-box-shadow: var(--pc-shadow-lg); --bs-dropdown-font-size: var(--pc-fs-base);
  --bs-dropdown-link-color: var(--pc-text); --bs-dropdown-link-hover-bg: var(--pc-hover);
  --bs-dropdown-link-active-bg: var(--pc-accent-soft); --bs-dropdown-link-active-color: var(--pc-accent);
  --bs-dropdown-item-padding-x: .625rem; --bs-dropdown-item-padding-y: .4375rem;
  --bs-dropdown-padding-x: 4px; --bs-dropdown-padding-y: 4px; --bs-dropdown-divider-margin-y: 4px;
  min-width: 13rem; box-shadow: var(--bs-dropdown-box-shadow);
}
.dropdown-item { border-radius: var(--pc-radius-xs); display: flex; align-items: center; }
.dropdown-item i { color: var(--pc-subtle); width: 16px; }
.dropdown-item.text-danger i { color: inherit; }
.dropdown-item.text-danger:hover { background: var(--pc-danger-soft); }
.modal { --bs-modal-border-radius: 12px; --bs-modal-border-color: var(--pc-border); --bs-modal-box-shadow: var(--pc-shadow-lg); --bs-modal-padding: var(--pc-sp-6); --bs-modal-header-padding: var(--pc-sp-6) var(--pc-sp-6) 0; --bs-modal-footer-gap: var(--pc-sp-2); }
.modal-content { box-shadow: var(--pc-shadow-lg); }
.modal-title { font-size: var(--pc-fs-lg) !important; font-weight: 600; }
.modal-body { color: var(--pc-text-secondary); font-size: var(--pc-fs-base); padding-top: var(--pc-sp-2); }
.modal-footer { padding: 0 var(--pc-sp-6) var(--pc-sp-6); }
.modal-footer > * { margin: 0; }
.modal-backdrop { --bs-backdrop-bg: #101828; --bs-backdrop-opacity: .4; }
.tooltip { --bs-tooltip-bg: var(--pc-text); --bs-tooltip-font-size: var(--pc-fs-xs); --bs-tooltip-border-radius: var(--pc-radius-xs); }

/* ==========================================================================
   Contraseña temporal
   ========================================================================== */
.secret-box {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 1.25rem; letter-spacing: .06em; padding: 14px var(--pc-sp-4);
  background: var(--pc-surface-subtle); border: 1px dashed var(--pc-border-strong); border-radius: var(--pc-radius-sm);
  user-select: all; word-break: break-all;
}

/* ==========================================================================
   Pantallas de acceso y error
   ========================================================================== */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--pc-sp-6) var(--pc-sp-4);
  background: var(--pc-bg);
}
.auth-card { width: 100%; max-width: 400px; }
.auth-card .card { box-shadow: var(--pc-shadow-md); }
.auth-card .card-body { padding: var(--pc-sp-8); }
.auth-card h1 { font-size: var(--pc-fs-lg) !important; letter-spacing: -.015em; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: var(--pc-sp-3); text-align: center; margin-bottom: var(--pc-sp-6); }
.auth-brand .brand-title { font-size: var(--pc-fs-md); }
.auth-footer { text-align: center; font-size: var(--pc-fs-xs); color: var(--pc-subtle); margin-top: var(--pc-sp-5); }
.error-code { font-size: var(--pc-fs-xs); font-weight: 600; letter-spacing: .08em; color: var(--pc-subtle); text-transform: uppercase; }

/* ==========================================================================
   Utilidades
   ========================================================================== */
.gap-row { row-gap: var(--pc-sp-4); }
.w-fit { width: fit-content; }
.min-w-0 { min-width: 0; }
.nowrap { white-space: nowrap; }
.fw-medium { font-weight: 500 !important; }
.divider-dot::before { content: "·"; margin: 0 6px; color: var(--pc-subtle); }
.visually-hidden-focusable:not(:focus):not(:focus-within) { position: absolute !important; }

@media (max-width: 575.98px) {
  .page-header { align-items: stretch; margin-bottom: var(--pc-sp-5); }
  .page-header h1 { font-size: 1.25rem; }
  .page-header > .btn, .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .page-actions .btn-icon { flex: 0 0 auto; }
  .form-section { padding: var(--pc-sp-5) var(--pc-sp-4); }
  .form-actions { padding: 14px var(--pc-sp-4); }
  .form-actions .btn { flex: 1; }
  .form-actions .form-actions-note { flex-basis: 100%; }
  .auth-card .card-body { padding: var(--pc-sp-6) var(--pc-sp-5); }
  .list-row, .cat-bar { padding-left: var(--pc-sp-4); padding-right: var(--pc-sp-4); }
  .card-header { padding-left: var(--pc-sp-4); padding-right: var(--pc-sp-4); }
  .stat-item { padding: var(--pc-sp-4); }
  .stat-item .stat-value { font-size: 1.5rem; }
  /* Montos de 9 dígitos ("$171.209.844") en media columna: más chicos y sin cortar. */
  .stat-strip:not(.cols-2) .stat-item .stat-value { font-size: 1.1875rem; white-space: nowrap; }
  .mix-row { padding-left: var(--pc-sp-4); padding-right: var(--pc-sp-4); }
}

/* Movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: .001s !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .btn.is-loading::before { animation: pc-spin 1.4s linear infinite !important; animation-iteration-count: infinite !important; }
}

/* Impresión */
@media print {
  .app-sidebar, .app-topbar, .page-actions, .form-actions, .messages-stack { display: none !important; }
  .app-content { padding: 0; max-width: none; }
  .card { box-shadow: none; }
}
