/**
 * Pont & Asociados — Admin Design System
 * Sistema de diseño unificado para el panel de administración.
 * Versión premium: tokens globales, componentes coherentes, estética institucional.
 */

/* ==========================================================================
   DESIGN TOKENS — Variables globales del sistema
   ========================================================================== */
:root {
  /* Brand */
  --pont-gold:          #b8962e;
  --pont-gold-dark:     #9e7f22;
  --pont-gold-deeper:   #7a5f18;
  --pont-gold-light:    #f4eee1;
  --pont-gold-lighter:  #fbf9f4;
  --pont-gold-border:   #e2d2b0;
  --pont-dark:          #0a0805;
  --pont-dark-mid:      #14171f;
  --pont-dark-soft:     #1f2430;

  /* Surface */
  --surface-page:       #f5f6f8;
  --surface-card:       #ffffff;
  --surface-raised:     #f8fafc;
  --surface-sunken:     #f1f5f9;
  --surface-overlay:    rgba(255,255,255,0.96);

  /* Text */
  --text-primary:       #0f172a;
  --text-secondary:     #475569;
  --text-tertiary:      #94a3b8;
  --text-disabled:      #cbd5e1;
  --text-inverted:      #ffffff;
  --text-brand:         #785e13;

  /* Border */
  --border-base:        #e2e8f0;
  --border-strong:      #cbd5e1;
  --border-subtle:      #f1f5f9;
  --border-brand:       rgba(184, 150, 46, 0.45);

  /* Semantic */
  --color-success:      #16a34a;
  --color-success-bg:   #f0fdf4;
  --color-warning:      #d97706;
  --color-warning-bg:   #fffbeb;
  --color-danger:       #dc2626;
  --color-danger-bg:    #fef2f2;
  --color-info:         #0284c7;
  --color-info-bg:      #f0f9ff;

  /* Spacing scale */
  --space-1:  0.25rem;   /* 4px */
  --space-2:  0.5rem;    /* 8px */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;      /* 16px */
  --space-5:  1.25rem;   /* 20px */
  --space-6:  1.5rem;    /* 24px */
  --space-8:  2rem;      /* 32px */
  --space-10: 2.5rem;    /* 40px */

  /* Typography */
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, monospace;
  --font-display: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;

  --text-xs:    0.68rem;
  --text-sm:    0.78rem;
  --text-base:  0.875rem;
  --text-md:    0.95rem;
  --text-lg:    1.05rem;
  --text-xl:    1.2rem;
  --text-2xl:   1.45rem;

  /* Radius: Sistema rectilíneo Pont (0px) con mínimas excepciones funcionales */
  --radius-none:  0px;
  --radius-sm:    2px;
  --radius-base:  2px;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:   0 10px 30px rgba(0,0,0,0.10), 0 4px 10px rgba(0,0,0,0.05);
  --shadow-brand: 0 4px 14px rgba(184,150,46,0.25);

  /* Transitions */
  --transition-fast:   0.12s ease;
  --transition-base:   0.18s ease;
  --transition-slow:   0.28s ease;

  /* CoreUI override */
  --cui-body-font-family: var(--font-sans);
  --cui-body-color:       var(--text-primary);
  --cui-body-bg:          var(--surface-page);
}

/* ==========================================================================
   RESET TIPOGRÁFICO — Unificación completa
   ========================================================================== */
html,
body,
input,
select,
textarea,
button,
table,
td,
th,
p,
h1, h2, h3, h4, h5, h6,
.badge,
.form-control,
.form-select,
code,
pre,
kbd,
samp,
.ficha-table,
.sms-verbatim-box {
  font-family: var(--font-sans) !important;
}

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  font-size: var(--text-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--surface-page);
}

/* Protección íconos FontAwesome */
.fa, .fas, .fa-solid, .fa-solid::before {
  font-family: var(--fa-style-family, "Font Awesome 6 Free") !important;
  font-weight: 900 !important;
}
.far, .fa-regular, .fa-regular::before {
  font-family: var(--fa-style-family, "Font Awesome 6 Free") !important;
  font-weight: 400 !important;
}
.fab, .fa-brands, .fab::before, .fa-brands::before {
  font-family: "Font Awesome 6 Brands" !important;
  font-weight: 400 !important;
}
[class^="fa-"]:not(.fa-brands):not(.fab)::before,
[class*=" fa-"]:not(.fa-brands):not(.fab)::before {
  font-family: var(--fa-style-family, "Font Awesome 6 Free") !important;
}

/* ==========================================================================
   REGLA MAESTRA — Sistema rectilíneo Pont y Asociados
   ========================================================================== */
.modal-content, .modal-header, .modal-body, .modal-footer, .modal-dialog,
.card, .card-header, .card-body, .card-footer,
.btn, .btn-group,
.form-control, .form-select,
.input-group, .input-group-text,
.dropdown-menu, .dropdown-item,
.alert, .badge, .table,
.nav-pills .nav-link, .nav-tabs .nav-link,
.pagination .page-item .page-link,
.list-group, .list-group-item {
  border-radius: var(--radius-none) !important;
}

/* ==========================================================================
   SIDEBAR — Navegación lateral premium
   ========================================================================== */
.coreui-sidebar {
  background: #12151d !important;
  border-right: 1px solid #1e2332 !important;
  box-shadow: none !important;
}

.coreui-sidebar .sidebar-header {
  background: #0d1018 !important;
  border-bottom: 1px solid #1e2332 !important;
  padding: 0 !important;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.sidebar-brand-wrapper {
  width: 100%;
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  user-select: none;
}

.sidebar-brand-logo-img {
  max-height: 34px;
  max-width: 155px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  transition: opacity var(--transition-base);
}

.sidebar-brand-edit-pill {
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  background: #1e2332;
  border: 1px solid #2d3447;
  color: #9ca3af;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.coreui-sidebar .sidebar-header:hover .sidebar-brand-edit-pill {
  opacity: 1;
  pointer-events: auto;
}

/* Nav titles */
.coreui-sidebar .sidebar-nav {
  padding: 0.5rem 0.4rem !important;
}

.coreui-sidebar .sidebar-nav .nav-title {
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #4b5563;
  margin-top: 1rem;
  margin-bottom: 0.2rem;
  padding: 0.3rem 0.85rem;
}

.coreui-sidebar .sidebar-nav .nav-title::before {
  display: none !important;
}

.coreui-sidebar .sidebar-nav .nav-item {
  margin-bottom: 1px;
}

/* Nav links */
.coreui-sidebar .sidebar-nav .nav-link {
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.52rem 0.85rem;
  color: #8a94a6;
  border-radius: var(--radius-sm);
  border-left: none !important;
  display: flex;
  align-items: center;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  box-shadow: none !important;
  letter-spacing: 0.01em;
}

.coreui-sidebar .sidebar-nav .nav-link .nav-icon {
  color: #5a6478;
  font-size: 0.88rem;
  width: 1.5rem;
  margin-right: 0.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
  flex-shrink: 0;
}

/* Hover */
.coreui-sidebar .sidebar-nav .nav-link:hover {
  color: #e2e8f0;
  background: #1c2131 !important;
}

.coreui-sidebar .sidebar-nav .nav-link:hover .nav-icon {
  color: #9ca3af;
}

/* Active */
.coreui-sidebar .sidebar-nav .nav-link.active {
  color: #ffffff !important;
  background: rgba(184, 150, 46, 0.18) !important;
  border: 1px solid rgba(184, 150, 46, 0.38) !important;
  font-weight: 600;
}

.coreui-sidebar .sidebar-nav .nav-link.active .nav-icon {
  color: #c9a842 !important;
}

.coreui-sidebar .sidebar-nav .nav-link.active .nav-text {
  color: #ffffff !important;
}

/* Badges en sidebar */
.coreui-sidebar .sidebar-nav .nav-link .badge {
  font-size: 0.63rem;
  padding: 0.18rem 0.42rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

#badge-nav-webmail {
  background: #2d3447 !important;
  color: #e2e8f0 !important;
  border: 1px solid rgba(255,255,255,0.12);
}

.coreui-sidebar .sidebar-nav .nav-link.active #badge-nav-webmail {
  background: var(--pont-gold) !important;
  color: #ffffff !important;
  border: none;
}

#badge-nav-deadlines {
  background: var(--color-danger) !important;
  color: #ffffff !important;
  border: none !important;
}

/* ==========================================================================
   HEADER — Barra superior
   ========================================================================== */
.header.header-sticky {
  padding-top: 0.45rem !important;
  padding-bottom: 0.45rem !important;
  min-height: auto !important;
  position: sticky !important;
  z-index: 1050 !important;
  background: #ffffff !important;
  border-bottom: 1px solid var(--border-base) !important;
  box-shadow: var(--shadow-sm) !important;
}

#global-search-wrapper {
  z-index: 1060 !important;
}

/* Wrapper layout */
@media (min-width: 992px) {
  .wrapper {
    padding-left: var(--cui-sidebar-occupy-width, 256px);
    transition: padding-left 0.18s ease-in-out;
    will-change: padding-left;
  }
  .sidebar.hide ~ .wrapper,
  .sidebar.sidebar-narrow-unfoldable:not(:hover) ~ .wrapper {
    padding-left: 0;
  }
}

/* ==========================================================================
   GLOBAL SEARCH — Búsqueda con resultados clasificados
   ========================================================================== */
.global-search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  width: 100%;
  max-height: 540px;
  background: var(--surface-card);
  border: 1px solid var(--border-brand);
  box-shadow: 0 20px 50px rgba(0,0,0,0.18), 0 4px 12px rgba(0,0,0,0.07);
  overflow-y: auto;
  z-index: 99999 !important;
  color: var(--text-primary);
}

.search-category-header {
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border-base);
  border-top: 1px solid var(--border-base);
  padding: 6px 14px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--pont-gold-deeper);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.search-category-header:first-child {
  border-top: none;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
  text-decoration: none;
  background: var(--surface-card);
}

.search-result-item:hover,
.search-result-item:focus {
  background: var(--pont-gold-lighter);
  outline: none;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 0.9rem;
  background: var(--surface-raised);
  border: 1px solid var(--border-base);
  color: var(--text-secondary);
}

.search-result-body {
  min-width: 0;
  flex-grow: 1;
}

.search-result-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.search-result-meta {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  margin-top: 2px;
}

.search-match-highlight {
  color: var(--pont-gold-deeper);
  background: rgba(184, 150, 46, 0.16);
  font-weight: 700;
  padding: 0 3px;
}

.search-empty-state {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--text-base);
  background: var(--surface-card);
}

.search-footer-info {
  background: var(--surface-raised);
  border-top: 1px solid var(--border-base);
  padding: 6px 14px;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  bottom: 0;
  z-index: 10;
}

/* ==========================================================================
   CARDS — Sistema de superficies
   ========================================================================== */
.card {
  border-radius: var(--radius-none) !important;
  border: 1px solid var(--border-base);
  box-shadow: none;
}

.card-header {
  border-radius: var(--radius-none) !important;
  background-color: var(--surface-card);
  border-bottom: 1px solid var(--border-base);
  font-weight: 700;
  font-size: var(--text-sm);
  padding: 0.8rem 1.2rem;
  color: var(--text-primary);
}

.widget-stat-card {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.widget-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md) !important;
}

/* ==========================================================================
   TABLAS — Sistema unificado de datos tabulares
   ========================================================================== */
.table {
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.table th {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-secondary);
  background-color: var(--surface-raised);
  border-bottom: 1px solid var(--border-base);
  white-space: nowrap;
  vertical-align: middle;
}

.table td {
  vertical-align: middle;
  border-bottom: 1px solid var(--border-subtle);
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover td {
  background-color: var(--pont-gold-lighter);
}

/* Sticky thead */
thead.sticky-top,
.table thead.sticky-top,
.table th,
.table thead th,
.table-responsive thead.sticky-top,
.card-body thead.sticky-top {
  z-index: 5 !important;
}

/* Empty state en tablas */
.table-empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-tertiary);
}

.table-empty-state i {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  display: block;
  opacity: 0.45;
}

.table-empty-state p {
  font-size: var(--text-sm);
  margin: 0;
}

/* ==========================================================================
   FORMULARIOS — Inputs, labels, selects
   ========================================================================== */
.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
}

.form-control, .form-select {
  font-size: var(--text-sm);
  border-color: var(--border-strong);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus, .form-select:focus {
  border-color: var(--pont-gold);
  box-shadow: 0 0 0 3px rgba(184, 150, 46, 0.14);
  outline: none;
}

.form-control::placeholder {
  color: var(--text-tertiary);
  opacity: 1;
}

.form-check-input:checked {
  background-color: var(--color-success);
  border-color: var(--color-success);
}

.form-check-input:focus {
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
}

/* Input groups */
.input-group-text {
  background: var(--surface-raised);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

/* ==========================================================================
   BOTONES — Sistema de 5 variantes
   ========================================================================== */
.btn {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.btn-primary {
  background: var(--pont-gold);
  border-color: var(--pont-gold);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--pont-gold-dark);
  border-color: var(--pont-gold-dark);
  color: #ffffff;
}

.btn-dark {
  background: var(--pont-dark);
  border-color: var(--pont-dark);
}

.btn-dark:hover {
  background: #1a1208;
  border-color: #1a1208;
}

.btn-outline-secondary:hover,
.btn-light:hover {
  background: var(--surface-sunken);
}

/* ==========================================================================
   DROPDOWNS
   ========================================================================== */
.dropdown-menu {
  border: 1px solid var(--border-base);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  padding: 0.35rem 0;
}

.dropdown-item {
  font-size: var(--text-sm);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.dropdown-item:hover, .dropdown-item:focus {
  background: var(--surface-sunken);
  color: var(--text-primary);
}

.dropdown-item.text-danger:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.dropdown-divider {
  border-color: var(--border-subtle);
  margin: 0.3rem 0;
}

/* ==========================================================================
   MODALES — Sistema consistente
   ========================================================================== */
.modal-content {
  border: 1px solid var(--border-base);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border-base);
  padding: 1rem 1.25rem;
}

.modal-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body {
  padding: 1.25rem;
  font-size: var(--text-base);
}

.modal-footer {
  border-top: 1px solid var(--border-base);
  padding: 0.85rem 1.25rem;
  gap: 0.5rem;
}

.btn-close {
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}

.btn-close:hover {
  opacity: 1;
}

/* ==========================================================================
   BADGES
   ========================================================================== */
.badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.22rem 0.5rem;
}

/* ==========================================================================
   ALERTAS
   ========================================================================== */
.alert {
  font-size: var(--text-sm);
  border-left-width: 3px;
  border-top: none;
  border-right: none;
  border-bottom: none;
  padding: 0.85rem 1rem;
}

/* ==========================================================================
   TREE — Carpetas y subcarpetas
   ========================================================================== */
.tree-node-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  transition: background var(--transition-fast);
}

.tree-node-row:hover {
  background: var(--surface-raised);
}

/* ==========================================================================
   DROPZONE — Carga de archivos
   ========================================================================== */
.coreui-dropzone {
  border: 2px dashed var(--border-strong);
  background: var(--surface-raised);
  padding: var(--space-8);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
}

.coreui-dropzone:hover,
.coreui-dropzone.dragover {
  border-color: var(--pont-gold);
  background: var(--pont-gold-lighter);
}

/* ==========================================================================
   FOLDER CARDS — Gestión documental
   ========================================================================== */
.folder-card {
  position: relative;
  overflow: hidden !important;
  background: var(--surface-card);
  min-width: 0 !important;
  transition: border-color var(--transition-base), box-shadow var(--transition-base), transform var(--transition-base);
  border: 1px solid var(--border-base);
}

.folder-card:hover {
  transform: translateY(-1px);
  border-color: var(--pont-gold) !important;
  box-shadow: 0 4px 14px rgba(184, 150, 46, 0.14) !important;
}

.folder-name-container {
  overflow: hidden !important;
  white-space: nowrap !important;
  position: relative !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  flex: 1 1 0% !important;
  display: block !important;
}

.folder-marquee-text,
.folder-title-text,
[data-marquee="true"] {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  line-height: 1.35;
  box-sizing: border-box;
  will-change: transform;
}

.folder-marquee-text.is-scrolling,
.folder-title-text.is-scrolling,
[data-marquee="true"].is-scrolling {
  display: inline-block !important;
  width: auto !important;
  max-width: none !important;
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: nowrap !important;
}

.folder-banner-path,
.folder-banner-title,
.folder-banner-full {
  white-space: normal !important;
  word-break: break-word !important;
  overflow-wrap: break-word !important;
  line-height: 1.45 !important;
  text-overflow: unset !important;
}

/* Folder tree select */
.folder-tree-select-row {
  transition: background var(--transition-fast), border-color var(--transition-fast);
  user-select: none;
}

.folder-tree-select-row:hover {
  background-color: var(--surface-sunken) !important;
}

.folder-tree-select-row.is-selected {
  background-color: var(--pont-gold-light) !important;
  border-left: 3px solid var(--pont-gold) !important;
}

/* ==========================================================================
   SWITCHES & TOGGLES
   ========================================================================== */
.btn-xs {
  padding: 0.15rem 0.4rem !important;
  font-size: var(--text-xs) !important;
  line-height: 1.4 !important;
}

/* ==========================================================================
   CALENDARIO
   ========================================================================== */
.cal-grid-header {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--border-base);
  border: 1px solid var(--border-base);
  border-bottom: none;
}

.cal-grid-header > div {
  background: var(--surface-raised);
  text-align: center;
  font-weight: 700;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.15rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--border-base);
  border: 1px solid var(--border-base);
}

.cal-cell {
  background: var(--surface-card);
  min-height: 80px;
  padding: 3px 4px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  border: 2px solid transparent;
  user-select: none;
  position: relative;
  overflow: hidden;
  min-width: 0;
  box-sizing: border-box;
}

.cal-cell:hover {
  background: var(--pont-gold-lighter);
  border-color: var(--pont-gold-border);
}

.cal-cell.cal-today {
  background: #fffef8;
  border-color: var(--pont-gold) !important;
}

.cal-cell.cal-today .cal-day-num-text {
  color: var(--pont-gold);
  font-weight: 800;
}

.cal-cell.cal-selected {
  background: var(--surface-raised);
  border-color: var(--pont-dark) !important;
  box-shadow: inset 0 0 0 1px var(--pont-dark);
}

.cal-cell.cal-other-month {
  background: #fafbfc;
  opacity: 0.45;
}

.cal-day-num {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
}

.cal-events-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: auto;
  overflow: hidden;
  min-width: 0;
  width: 100%;
}

.cal-event-dot {
  width: 6px;
  height: 6px;
  display: inline-block;
}

.cal-event-pill {
  font-size: 0.58rem !important;
  padding: 1.5px 3px;
  border-radius: var(--radius-sm);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
  -webkit-hyphens: auto;
  line-height: 1.15;
  font-weight: 600 !important;
  color: #ffffff !important;
  background-color: #0d6efd !important;
  border: 1px solid rgba(0,0,0,0.08) !important;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.cal-event-pill.pill-pending  { background-color: var(--color-warning) !important; }
.cal-event-pill.pill-overdue  { background-color: var(--color-danger) !important; }
.cal-event-pill.pill-done     { background-color: var(--color-success) !important; }

/* Week view */
.cal-week-grid-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cal-week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--border-base);
  border: 1px solid var(--border-base);
  min-height: 380px;
  width: 100%;
}

.cal-week-col {
  background: var(--surface-card);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.cal-week-col-header {
  background: var(--surface-raised);
  padding: 6px 3px;
  text-align: center;
  border-bottom: 1px solid var(--border-base);
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
}

.cal-week-col-header:hover { background: var(--surface-sunken); }

.cal-week-col.is-today .cal-week-col-header {
  background: #fffef2;
  border-bottom: 2px solid var(--pont-gold);
}

.cal-week-col.is-selected .cal-week-col-header {
  background: var(--pont-dark);
  color: #ffffff;
}

.cal-week-col.is-selected .cal-week-col-header * {
  color: #ffffff !important;
}

.cal-week-col-body {
  padding: 4px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: 420px;
}

.cal-week-card {
  background: var(--surface-raised);
  border: 1px solid var(--border-base);
  border-left: 3px solid #0d6efd;
  padding: 4px 5px;
  border-radius: var(--radius-sm);
  font-size: 0.62rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  word-break: break-word;
  line-height: 1.2;
}

.cal-week-card:hover {
  background: var(--surface-sunken);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.cal-week-card.card-pending  { border-left-color: var(--color-warning); }
.cal-week-card.card-overdue  { border-left-color: var(--color-danger); background: var(--color-danger-bg); }
.cal-week-card.card-done     { border-left-color: var(--color-success); opacity: 0.75; }

/* Day view */
.cal-day-container {
  background: var(--surface-card);
  border: 1px solid var(--border-base);
  padding: 14px;
  min-height: 380px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: 520px;
}

.cal-day-event-item {
  border: 1px solid var(--border-base);
  border-left: 4px solid #0d6efd;
  background: var(--surface-card);
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.cal-day-event-item:hover {
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.cal-day-event-item.is-overdue { border-left-color: var(--color-danger); background: var(--color-danger-bg); }
.cal-day-event-item.is-pending { border-left-color: var(--color-warning); }
.cal-day-event-item.is-done    { border-left-color: var(--color-success); opacity: 0.8; }

/* ==========================================================================
   SMS — Módulo de mensajería
   ========================================================================== */
.sms-detail-drawer {
  background: var(--surface-raised);
  border-top: 1px solid var(--border-base);
  border-bottom: 2px solid var(--pont-gold);
  padding: 1.25rem;
}

.sms-verbatim-box {
  background: var(--surface-card);
  border-left: 3px solid var(--pont-gold);
  padding: 0.85rem 1rem;
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--text-primary);
}

.sms-tpl-card {
  background: var(--surface-card);
  border: 1px solid var(--border-base);
  padding: 1rem 1.25rem;
  transition: all var(--transition-fast);
}

.sms-tpl-card:hover {
  border-color: var(--pont-gold);
  box-shadow: 0 4px 12px rgba(184, 150, 46, 0.08);
}

.sms-preview-phone {
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  padding: 1.25rem;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.sms-preview-bubble {
  background: var(--pont-dark);
  color: #ffffff;
  padding: 0.75rem 1rem;
  font-size: var(--text-sm);
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  position: relative;
  word-break: break-word;
}

/* ==========================================================================
   FICHA TÉCNICA
   ========================================================================== */
.ficha-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-card);
}

.ficha-table td {
  border: 1px solid var(--border-base);
  padding: 7px 12px !important;
  font-size: var(--text-xs);
}

.ficha-table tr:hover td {
  background-color: var(--surface-raised);
}

/* ==========================================================================
   DOCUMENT VIEWER — Modal de visualización de documentos
   ========================================================================== */
.doc-viewer-modal .modal-dialog {
  max-width: 92vw;
  margin: 1.25rem auto;
  transition: all 0.2s ease-out;
}

.doc-viewer-modal .modal-content {
  background: #0a0805 !important;
  color: #f1f5f9 !important;
  border: 1px solid rgba(184, 150, 46, 0.35) !important;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.75) !important;
}

.doc-viewer-header {
  background: #0a0805 !important;
  border-bottom: 1px solid rgba(184, 150, 46, 0.28) !important;
  padding: 0.5rem 1.25rem !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  box-shadow: 0 4px 18px rgba(0,0,0,0.4);
}

.doc-viewer-brand-logo {
  max-height: 28px;
  max-width: 130px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  pointer-events: none;
  user-select: none;
}

.doc-viewer-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: #e2e8f0;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.38rem 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.doc-viewer-btn:hover {
  background: rgba(255,255,255,0.18);
  color: #ffffff;
  border-color: #ffffff;
}

.doc-viewer-btn-gold {
  background: rgba(255,255,255,0.08) !important;
  border: 1px solid rgba(255,255,255,0.22) !important;
  color: #f1f5f9 !important;
}

.doc-viewer-btn-gold:hover {
  background: rgba(255,255,255,0.18) !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
}

.doc-viewer-btn-close {
  background: rgba(239,68,68,0.14) !important;
  border: 1px solid rgba(239,68,68,0.35) !important;
  color: #f87171 !important;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.38rem 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.doc-viewer-btn-close:hover {
  background: #ef4444 !important;
  color: #ffffff !important;
  border-color: #ef4444 !important;
}

.doc-viewer-body {
  padding: 0 !important;
  background: #181b24;
  height: calc(85vh - 54px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Fullscreen */
.doc-viewer-modal.is-maximized .modal-dialog,
.modal-fullscreen#doc-viewer-dialog,
.doc-viewer-modal .modal-dialog.modal-fullscreen {
  max-width: 100vw !important;
  width: 100vw !important;
  height: 100vh !important;
  min-height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  top: 0 !important;
  left: 0 !important;
  position: fixed !important;
  z-index: 99999 !important;
}

.doc-viewer-modal.is-maximized .modal-content,
.modal-fullscreen#doc-viewer-dialog .modal-content,
.doc-viewer-modal .modal-dialog.modal-fullscreen .modal-content {
  width: 100vw !important;
  height: 100vh !important;
  min-height: 100vh !important;
  border: none !important;
  display: flex !important;
  flex-direction: column !important;
}

.doc-viewer-modal.is-maximized .doc-viewer-body,
.modal-fullscreen#doc-viewer-dialog .doc-viewer-body,
.doc-viewer-modal .modal-dialog.modal-fullscreen .doc-viewer-body {
  flex: 1 1 auto !important;
  height: calc(100vh - 54px) !important;
  max-height: calc(100vh - 54px) !important;
  width: 100% !important;
  overflow-y: auto !important;
}

.doc-sheet-canvas {
  background: #181b24;
  padding: 2rem 1rem;
  min-height: 100%;
  display: flex;
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
}

.doc-sheet-paper {
  background: #ffffff;
  color: #1a1a1a;
  width: 100%;
  max-width: 880px;
  min-height: 750px;
  padding: 2.5rem 2rem;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  font-family: var(--font-sans);
  line-height: 1.8;
  font-size: 0.92rem;
  box-sizing: border-box;
}

/* Doc viewer mobile */
@media (max-width: 768px) {
  .doc-viewer-modal .modal-dialog {
    max-width: 100vw !important;
    width: 100vw !important;
    margin: 0 !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
  }
  .doc-viewer-modal .modal-content {
    height: 100dvh !important;
    min-height: 100dvh !important;
    border: none !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .doc-viewer-header {
    padding: 0.4rem 0.55rem !important;
    gap: 0.35rem !important;
    min-height: 48px !important;
  }
  .doc-viewer-brand-logo {
    max-height: 20px !important;
    max-width: 70px !important;
  }
  .doc-viewer-btn span, .doc-viewer-btn-close span, .btn-viewer span {
    display: none !important;
  }
  .doc-viewer-btn, .doc-viewer-btn-close, .btn-viewer {
    padding: 0.4rem 0.55rem !important;
    min-width: 36px !important;
    height: 36px !important;
    font-size: 0.85rem !important;
    gap: 0 !important;
  }
  .doc-viewer-body {
    flex: 1 1 auto !important;
    height: calc(100dvh - 48px) !important;
    max-height: calc(100dvh - 48px) !important;
  }
  .doc-sheet-canvas { padding: 0.5rem 0.35rem !important; }
  .doc-sheet-paper {
    padding: 1rem 0.75rem !important;
    min-height: auto !important;
    font-size: 0.84rem !important;
    box-shadow: none !important;
  }
  .docx-wrapper { padding: 0 !important; background: transparent !important; }
  .docx-wrapper > section.docx {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0.75rem !important;
    margin: 0 !important;
    box-shadow: none !important;
    min-height: auto !important;
  }
}

/* ==========================================================================
   ENLACES ÚTILES — Link cards
   ========================================================================== */
.link-card-container {
  display: flex;
  transition: transform var(--transition-base), opacity var(--transition-base);
}

.link-card-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface-card);
  border: 1px solid var(--border-base) !important;
  box-shadow: none;
  padding: 1.1rem;
  overflow: hidden;
  position: relative;
  transition: box-shadow var(--transition-base), border-color var(--transition-base), transform var(--transition-base);
}

.link-card-box:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(184, 150, 46, 0.45) !important;
  transform: translateY(-2px);
}

.link-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  min-width: 0;
  width: 100%;
}

.link-card-icon-box {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  background: var(--pont-gold-lighter);
  border: 1px solid rgba(184, 150, 46, 0.25);
  color: var(--pont-gold);
  font-size: 1rem;
  display: grid;
  place-items: center;
}

.link-card-title-wrap {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.link-card-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.link-card-url {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.link-card-desc {
  font-size: var(--text-xs);
  line-height: 1.45;
  color: var(--text-secondary);
  margin-bottom: 0.85rem;
  flex-grow: 1;
  min-height: 2.9em;
  max-height: 2.9em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.link-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
  flex-wrap: wrap;
}

.drag-handle {
  cursor: grab;
  color: var(--text-tertiary);
  padding: 2px 4px;
  touch-action: none;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.drag-handle:hover {
  color: var(--pont-gold);
  background: rgba(184, 150, 46, 0.1);
}

.drag-handle:active { cursor: grabbing; }

.sortable-ghost {
  opacity: 0.4;
  background: var(--surface-raised) !important;
  border: 1.5px dashed var(--pont-gold) !important;
}

.sortable-chosen {
  border-color: var(--pont-gold) !important;
  box-shadow: 0 8px 24px rgba(184, 150, 46, 0.2) !important;
}

.link-new-card-col { min-height: 168px; }

.link-card-new-btn {
  height: 100%;
  min-height: 168px;
  background: rgba(184, 150, 46, 0.03) !important;
  border: 2px dashed rgba(184, 150, 46, 0.45) !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.65rem !important;
  color: var(--pont-gold-deeper) !important;
  padding: 1.5rem 1rem !important;
  transition: all var(--transition-base) !important;
  cursor: pointer !important;
  text-decoration: none !important;
}

.link-card-new-btn:hover {
  background: rgba(184, 150, 46, 0.08) !important;
  border-color: var(--pont-gold) !important;
  color: var(--pont-gold-deeper) !important;
  transform: translateY(-2px);
  box-shadow: var(--shadow-brand) !important;
}

.link-new-plus-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(184, 150, 46, 0.12);
  border: 1.5px solid rgba(184, 150, 46, 0.4);
  color: var(--pont-gold);
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  transition: all var(--transition-base);
}

.link-card-new-btn:hover .link-new-plus-circle {
  background: var(--pont-gold);
  color: #ffffff;
  border-color: var(--pont-gold);
  transform: scale(1.08);
}

.link-new-text {
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Text truncation */
.text-truncate,
.folder-marquee-text,
.link-card-title,
.link-card-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-truncate::-webkit-scrollbar,
.folder-marquee-text::-webkit-scrollbar,
.link-card-title::-webkit-scrollbar,
.link-card-url::-webkit-scrollbar {
  display: none;
}

/* ==========================================================================
   WEBMAIL — Módulo de correo electrónico institucional
   ========================================================================== */
.webmail-workspace {
  background: var(--surface-card);
  border: 1px solid var(--border-base);
  box-shadow: var(--shadow-sm);
  display: flex;
  height: calc(100vh - 130px);
  min-height: 600px;
  overflow: hidden;
  position: relative;
}

/* Carpetas */
.webmail-folders-pane {
  width: 220px;
  min-width: 220px;
  background: #fbfcfd;
  border-right: 1px solid var(--border-base);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: width 0.22s cubic-bezier(0.4,0,0.2,1), min-width 0.22s cubic-bezier(0.4,0,0.2,1);
  position: relative;
}

.webmail-folders-pane.collapsed {
  width: 56px;
  min-width: 56px;
}

.webmail-folders-header {
  padding: 0.7rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.webmail-folders-pane.collapsed .webmail-folders-header {
  justify-content: center;
  padding: 0.7rem 0.3rem;
}

.webmail-folders-title {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.webmail-folders-pane.collapsed .webmail-folders-title { display: none; }

.btn-toggle-folders {
  background: none;
  border: none;
  color: var(--text-tertiary);
  padding: 3px 6px;
  cursor: pointer;
  font-size: 0.78rem;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.btn-toggle-folders:hover {
  color: var(--text-primary);
  background: var(--surface-sunken);
}

.webmail-compose-btn-wrap {
  padding: 0.7rem 0.85rem 0.5rem;
}

.webmail-folders-pane.collapsed .webmail-compose-btn-wrap {
  padding: 0.7rem 0.4rem 0.5rem;
  display: flex;
  justify-content: center;
}

.btn-webmail-compose {
  background: linear-gradient(135deg, var(--pont-gold) 0%, var(--pont-gold-dark) 100%);
  color: #ffffff !important;
  font-weight: 600;
  font-size: var(--text-sm);
  letter-spacing: 0.01em;
  padding: 0.52rem 0.85rem;
  border: none;
  box-shadow: 0 2px 8px rgba(184, 150, 46, 0.22);
  transition: all var(--transition-base);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.btn-webmail-compose:hover {
  background: linear-gradient(135deg, var(--pont-gold-dark) 0%, var(--pont-gold-deeper) 100%);
  box-shadow: 0 4px 12px rgba(184, 150, 46, 0.32);
  transform: translateY(-1px);
}

.webmail-folders-pane.collapsed .btn-webmail-compose {
  width: 36px;
  height: 36px;
  padding: 0;
  gap: 0;
}

.webmail-folders-pane.collapsed .btn-webmail-compose span { display: none; }

.webmail-folder-nav {
  list-style: none;
  padding: 0.3rem 0.5rem;
  margin: 0;
  overflow-y: auto;
  flex-grow: 1;
}

.webmail-folders-pane.collapsed .webmail-folder-nav {
  padding: 0.3rem 0.25rem;
}

.webmail-folder-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  padding: 0.48rem 0.7rem;
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 1px;
  transition: all var(--transition-fast);
  border-left: 2px solid transparent;
  user-select: none;
  position: relative;
}

.webmail-folders-pane.collapsed .webmail-folder-item {
  justify-content: center;
  padding: 0.6rem 0;
  gap: 0;
}

.webmail-folder-item:hover {
  background: var(--surface-sunken);
  color: var(--text-primary);
}

.webmail-folder-item.active {
  background: var(--pont-gold-light);
  color: var(--pont-gold-deeper);
  font-weight: 700;
  border-left-color: var(--pont-gold);
}

.webmail-folder-item i {
  width: 18px;
  text-align: center;
  font-size: 0.88rem;
  flex-shrink: 0;
}

.webmail-folders-pane.collapsed .webmail-folder-item i {
  font-size: 1.1rem;
  width: auto;
}

.webmail-folder-name {
  flex: 1 1 auto;
  text-align: left;
  margin: 0;
  min-width: 0;
  line-height: 1.25;
  display: inline-block;
}

.webmail-folders-pane.collapsed .webmail-folder-name { display: none; }

.webmail-folder-badge {
  margin-left: auto;
  flex-shrink: 0;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  background: var(--surface-sunken);
  color: var(--text-secondary);
}

.webmail-folder-item.active .webmail-folder-badge {
  background: var(--pont-gold);
  color: #ffffff;
}

.webmail-folders-pane.collapsed .webmail-folder-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 1px 3px;
  font-size: 0.55rem;
  border-radius: 8px;
}

.webmail-server-status {
  padding: 0.6rem 0.85rem;
  border-top: 1px solid var(--border-base);
  background: var(--surface-card);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.webmail-folders-pane.collapsed .webmail-server-status {
  justify-content: center;
  padding: 0.6rem 0;
}

.webmail-folders-pane.collapsed .webmail-server-status span.server-label { display: none; }

/* Main stack */
.webmail-main-stack {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--surface-card);
}

/* List pane */
.webmail-top-list-pane {
  height: 42%;
  min-height: 220px;
  max-height: 48%;
  display: flex;
  flex-direction: column;
  border-bottom: 2px solid var(--border-base);
  background: var(--surface-card);
  position: relative;
}

.webmail-list-header {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border-base);
  background: var(--surface-raised);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.webmail-search-box {
  position: relative;
  width: 260px;
  max-width: 100%;
}

.webmail-search-box input {
  font-size: var(--text-xs);
  padding-left: 2rem;
  border: 1px solid var(--border-strong);
  background: var(--surface-card);
  height: 30px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.webmail-search-box input:focus {
  border-color: var(--pont-gold);
  box-shadow: 0 0 0 2px rgba(184, 150, 46, 0.14);
}

.webmail-search-box .search-icon {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 0.72rem;
}

.webmail-filter-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
}

.webmail-tab-btn {
  background: none;
  border: 1px solid transparent;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  padding: 3px 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.webmail-tab-btn:hover {
  color: var(--text-primary);
  background: var(--surface-sunken);
}

.webmail-tab-btn.active {
  background: var(--pont-gold-light);
  color: var(--pont-gold-deeper);
  border-color: var(--pont-gold-border);
}

.webmail-messages-scroll {
  flex-grow: 1;
  overflow-y: auto;
  background: var(--surface-card);
}

/* Webmail table */
.webmail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.webmail-table th {
  position: sticky;
  top: 0;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border-base);
  padding: 6px 10px;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 5;
}

.webmail-table-row {
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
  user-select: none;
}

.webmail-table-row:hover { background: var(--surface-raised); }
.webmail-table-row.active { background: var(--pont-gold-lighter) !important; }

.webmail-table-row.unread { background: var(--surface-card); font-weight: 700; }
.webmail-table-row.unread td { color: var(--text-primary); }

.webmail-table td {
  padding: 7px 10px;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-status  { width: 44px; text-align: center; padding-right: 4px !important; }
.cell-from    { width: 220px; max-width: 240px; color: var(--text-primary); }
.cell-subject { max-width: 450px; color: var(--text-primary); }
.cell-date    { width: 130px; text-align: right; color: var(--text-secondary); font-size: var(--text-xs); }
.cell-size    { width: 70px; text-align: right; color: var(--text-tertiary); font-size: var(--text-xs); }

.msg-unread-dot {
  width: 8px;
  height: 8px;
  background: #3b82f6;
  border-radius: 50%;
  display: inline-block;
}

.msg-star-btn {
  background: none;
  border: none;
  padding: 0 3px;
  color: var(--text-disabled);
  cursor: pointer;
  font-size: 0.78rem;
  transition: color var(--transition-fast);
}

.msg-star-btn:hover, .msg-star-btn.starred { color: #eab308; }

/* Reading pane */
.webmail-bottom-reading-pane {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 58%;
  overflow-y: auto;
  background: var(--surface-card);
}

.webmail-reading-toolbar {
  padding: 0.55rem 1.2rem;
  border-bottom: 1px solid var(--border-base);
  background: var(--surface-raised);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

.webmail-reading-header {
  padding: 1rem 1.4rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-card);
}

.webmail-reading-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.55rem;
  line-height: 1.3;
}

.webmail-sender-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.webmail-sender-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--pont-gold-light) 0%, var(--pont-gold-border) 100%);
  color: var(--pont-gold-deeper);
  font-weight: 700;
  font-size: 0.9rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--pont-gold-border);
  flex-shrink: 0;
}

.webmail-attachments-section {
  padding: 0.7rem 1.4rem;
  border-top: 1px solid var(--border-base);
  background: var(--surface-raised);
}

.webmail-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface-card);
  border: 1px solid var(--border-strong);
  padding: 0.22rem 0.5rem;
  font-size: var(--text-xs);
  color: var(--text-primary);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.webmail-attachment-chip:hover {
  background: var(--surface-raised);
  border-color: var(--pont-gold);
  color: var(--text-primary);
}

/* Webmail action tiles */
.webmail-action-tile {
  background: var(--surface-card) !important;
  border: 1px solid var(--border-strong) !important;
  color: var(--text-primary) !important;
  text-decoration: none !important;
  transition: all var(--transition-base);
  cursor: pointer;
  box-shadow: none;
}

.webmail-action-tile:hover {
  background: var(--surface-raised) !important;
  border-color: var(--pont-gold) !important;
  box-shadow: 0 4px 12px rgba(184,150,46,0.12) !important;
  color: var(--text-primary) !important;
}

.webmail-action-tile.active {
  background: var(--pont-gold-lighter) !important;
  border-color: var(--pont-gold) !important;
  border-left: 3px solid var(--pont-gold) !important;
}

/* Reading body */
.webmail-reading-body {
  flex-grow: 1;
  padding: 1.4rem;
  overflow-y: auto;
  background: var(--surface-card);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--text-primary);
}

.webmail-reading-body img { max-width: 100% !important; height: auto !important; }
.webmail-reading-body table { max-width: 100% !important; }
.webmail-reading-body a { color: var(--pont-gold); text-decoration: underline; }
.webmail-reading-body a:hover { color: var(--pont-gold-dark); }
.webmail-reading-body blockquote {
  border-left: 3px solid var(--pont-gold);
  padding-left: 12px;
  margin-left: 0;
  color: var(--text-secondary);
}

/* Empty state webmail */
.webmail-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-tertiary);
}

.webmail-empty-icon {
  width: 50px;
  height: 50px;
  background: var(--surface-raised);
  border: 1px solid var(--border-base);
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  color: var(--text-tertiary);
  margin-bottom: 0.75rem;
}

/* Compose */
.webmail-compose-dialog { max-width: 780px; }

.webmail-compose-toolbar {
  background: var(--surface-raised);
  border: 1px solid var(--border-base);
  border-bottom: none;
  padding: 4px 8px;
  display: flex;
  gap: 4px;
}

.webmail-compose-toolbar button {
  background: none;
  border: none;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding: 3px 6px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.webmail-compose-toolbar button:hover {
  background: var(--surface-sunken);
  color: var(--text-primary);
}

.webmail-compose-editor {
  border: 1px solid var(--border-base);
  min-height: 220px;
  max-height: 380px;
  overflow-y: auto;
  padding: 0.85rem;
  font-size: var(--text-sm);
  line-height: 1.55;
  background: var(--surface-card);
  outline: none;
  transition: border-color var(--transition-fast);
}

.webmail-compose-editor:focus {
  border-color: var(--pont-gold);
}

/* Giant reading modal */
.webmail-giant-modal {
  max-width: 95vw !important;
  width: 95vw !important;
  margin: 1rem auto !important;
}

@media (min-width: 1400px) {
  .webmail-giant-modal { max-width: 1380px !important; }
}

.webmail-giant-reading-body {
  font-size: var(--text-md);
  line-height: 1.7;
  color: var(--text-primary);
  min-height: 350px;
  max-height: calc(85vh - 240px);
  overflow-y: auto;
  background: var(--surface-card);
  padding: 1.75rem 2rem;
  border: 1px solid var(--border-base);
}

.webmail-giant-reading-body blockquote {
  border-left: 3px solid var(--pont-gold);
  padding-left: 14px;
  margin: 1rem 0;
  color: var(--text-secondary);
}

.webmail-giant-reading-body img { max-width: 100% !important; height: auto !important; }

/* Webmail responsive */
@media (max-width: 991.98px) {
  .webmail-workspace {
    flex-direction: column !important;
    height: auto !important;
    min-height: auto !important;
  }
  .webmail-folders-pane {
    width: 100% !important;
    min-width: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border-base) !important;
  }
  .webmail-folders-pane .webmail-folder-nav { max-height: 180px; overflow-y: auto; }
  .webmail-folders-pane.collapsed .webmail-folder-nav { display: none !important; }
  .webmail-folders-pane.collapsed .webmail-server-status { display: none !important; }
  .webmail-folders-pane.collapsed .webmail-compose-btn-wrap {
    display: block !important;
    padding: 0.5rem 0.75rem !important;
  }
  .webmail-folders-pane.collapsed .btn-webmail-compose {
    width: 100% !important;
    height: auto !important;
    padding: 0.5rem 0.75rem !important;
    gap: 0.45rem !important;
  }
  .webmail-folders-pane.collapsed .btn-webmail-compose span { display: inline !important; }
  .webmail-top-list-pane {
    height: 380px !important;
    min-height: 280px !important;
    max-height: 420px !important;
  }
}

@media (max-width: 767.98px) {
  .webmail-list-header {
    padding: 0.5rem 0.65rem !important;
    gap: 0.4rem !important;
  }
  .webmail-search-box { width: 100% !important; }
  .webmail-filter-tabs {
    overflow-x: auto;
    width: 100%;
    scrollbar-width: none;
  }
  .webmail-filter-tabs::-webkit-scrollbar { display: none; }
  .webmail-table { table-layout: fixed !important; width: 100% !important; }
  .webmail-table th.cell-status, .webmail-table td.cell-status { width: 38px !important; padding: 6px 2px !important; }
  .webmail-table th.cell-from,  .webmail-table td.cell-from   { width: 42% !important; padding: 7px 4px !important; font-size: var(--text-xs) !important; }
  .webmail-table th.cell-subject, .webmail-table td.cell-subject { width: 58% !important; padding: 7px 6px !important; }
  .webmail-reading-toolbar { padding: 0.5rem 0.65rem !important; flex-wrap: wrap !important; }
  .webmail-reading-header { padding: 0.75rem 0.85rem !important; }
  .webmail-reading-title { font-size: var(--text-base) !important; }
  .webmail-reading-body { padding: 0.85rem !important; font-size: var(--text-sm) !important; }
  .webmail-attachments-section { padding: 0.65rem 0.85rem !important; }
  .webmail-attachment-chip { font-size: var(--text-xs) !important; padding: 0.22rem 0.4rem !important; }
  .webmail-giant-modal { max-width: 100vw !important; width: 100vw !important; margin: 0 !important; }
  .webmail-giant-reading-body { padding: 0.85rem !important; font-size: var(--text-sm) !important; max-height: calc(85vh - 200px) !important; }
  .webmail-compose-toolbar { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .webmail-compose-toolbar::-webkit-scrollbar { display: none; }
  .webmail-compose-editor { min-height: 160px !important; max-height: 260px !important; }
}

/* ==========================================================================
   CHAT — Módulo de comunicaciones internas
   Integrado al design system Pont (0px radius, paleta gold/dark)
   ========================================================================== */
.chat-container {
  display: flex;
  height: calc(100vh - 138px);
  background: var(--surface-card);
  border: 1px solid var(--border-base);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.chat-sidebar {
  width: 280px;
  min-width: 280px;
  border-right: 1px solid var(--border-base);
  display: flex;
  flex-direction: column;
  background: var(--surface-raised);
}

.chat-sidebar-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-base);
  background: var(--surface-card);
}

.chat-sidebar-title {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin: 0;
}

.chat-contacts {
  flex-grow: 1;
  overflow-y: auto;
}

.chat-contact {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border-subtle);
  gap: 0.75rem;
  position: relative;
}

.chat-contact:hover {
  background: var(--surface-sunken);
}

.chat-contact.active {
  background: var(--pont-gold-light);
  border-left: 3px solid var(--pont-gold);
}

.chat-contact-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.chat-contact-avatar {
  width: 38px;
  height: 38px;
  object-fit: cover;
  display: block;
  background: var(--surface-sunken);
  border: 1px solid var(--border-base);
  /* Sin border-radius — sistema rectilíneo */
}

.chat-contact-avatar-fallback {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--pont-gold-light) 0%, var(--pont-gold-border) 100%);
  color: var(--pont-gold-deeper);
  font-weight: 700;
  font-size: 0.9rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 1px solid var(--pont-gold-border);
}

.chat-contact-info {
  flex-grow: 1;
  min-width: 0;
}

.chat-contact-name {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.chat-contact-role {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: capitalize;
  line-height: 1.3;
}

.chat-unread-badge {
  background: var(--color-danger);
  color: #ffffff;
  font-size: 0.63rem;
  font-weight: 700;
  padding: 2px 6px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* Main chat area */
.chat-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface-card);
  min-width: 0;
}

.chat-header {
  padding: 0.75rem 1.2rem;
  border-bottom: 1px solid var(--border-base);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: var(--surface-raised);
}

.chat-header-avatar {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border: 1px solid var(--border-base);
  flex-shrink: 0;
}

.chat-header-avatar-fallback {
  width: 34px;
  height: 34px;
  background: var(--pont-gold-light);
  color: var(--pont-gold-deeper);
  font-weight: 700;
  font-size: 0.85rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--pont-gold-border);
  flex-shrink: 0;
}

.chat-header-info {
  flex-grow: 1;
  min-width: 0;
}

.chat-header-name {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.3;
}

.chat-header-role {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: capitalize;
}

/* Messages area */
.chat-messages {
  flex-grow: 1;
  padding: 1.25rem;
  overflow-y: auto;
  background: #f4f6f9;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-tertiary);
  text-align: center;
  gap: 0.5rem;
}

.chat-empty-state i {
  font-size: 2.25rem;
  opacity: 0.3;
}

.chat-empty-state p {
  font-size: var(--text-sm);
  margin: 0;
}

.chat-date-divider {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin: 0.75rem 0 0.25rem;
  position: relative;
}

.chat-date-divider::before,
.chat-date-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: var(--border-base);
}

.chat-date-divider::before { left: 0; }
.chat-date-divider::after  { right: 0; }

/* Message bubbles */
.chat-message {
  display: flex;
  margin-bottom: 0.35rem;
}

.chat-message.sent {
  justify-content: flex-end;
}

.chat-message.received {
  justify-content: flex-start;
}

.chat-message-content {
  max-width: 68%;
  padding: 0.65rem 0.9rem;
  font-size: var(--text-sm);
  line-height: 1.45;
  position: relative;
  word-break: break-word;
  /* Sin border-radius — sistema rectilíneo Pont */
}

.chat-message.received .chat-message-content {
  background: var(--surface-card);
  color: var(--text-primary);
  border: 1px solid var(--border-base);
  box-shadow: var(--shadow-sm);
}

.chat-message.sent .chat-message-content {
  background: var(--pont-dark);
  color: #f1f5f9;
  border: 1px solid transparent;
}

.chat-message-time {
  font-size: 0.65rem;
  margin-top: 0.2rem;
  opacity: 0.55;
  display: block;
  text-align: right;
}

/* File attachments in chat */
.chat-attachment {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.65rem;
  margin-top: 0.45rem;
  color: inherit;
  text-decoration: none;
  word-break: break-all;
  font-size: var(--text-xs);
  background: rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.08);
}

.chat-message.sent .chat-attachment {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.15);
  color: #e2e8f0;
}

.chat-attachment:hover {
  text-decoration: underline;
}

.chat-attachment img {
  max-width: 100%;
  max-height: 220px;
  display: block;
  margin-top: 0.35rem;
  object-fit: contain;
}

/* Input area */
.chat-file-preview {
  margin: 0.5rem 1rem 0;
  padding: 0.45rem 0.65rem;
  background: var(--pont-gold-lighter);
  border: 1px solid var(--pont-gold-border);
  font-size: var(--text-xs);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--pont-gold-deeper);
}

.chat-input-area {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border-base);
  display: flex;
  align-items: flex-end;
  background: var(--surface-card);
  gap: 0.5rem;
}

.chat-input {
  flex-grow: 1;
  border: 1px solid var(--border-strong);
  padding: 0.5rem 0.85rem;
  outline: none;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  font-size: var(--text-sm);
  line-height: 1.45;
  background: var(--surface-card);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  /* Sin border-radius */
}

.chat-input:focus {
  border-color: var(--pont-gold);
  box-shadow: 0 0 0 2px rgba(184, 150, 46, 0.14);
}

.chat-input::placeholder {
  color: var(--text-tertiary);
}

.chat-btn {
  width: 36px;
  height: 36px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  /* Sin border-radius — cuadrado */
}

.chat-btn-attach {
  background: var(--surface-sunken);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}

.chat-btn-attach:hover {
  background: var(--surface-raised);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.chat-btn-send {
  background: var(--pont-dark);
  color: #ffffff;
}

.chat-btn-send:hover {
  background: var(--pont-dark-soft);
}

.chat-btn-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Chat responsive */
@media (max-width: 767.98px) {
  .chat-container {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 160px);
  }
  .chat-sidebar {
    width: 100%;
    min-width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-base);
    max-height: 220px;
  }
  .chat-messages {
    min-height: 280px;
    max-height: 50vh;
  }
  .chat-message-content {
    max-width: 82%;
  }
}

/* ==========================================================================
   AGENDA — Directorio de contactos
   ========================================================================== */
.agenda-az-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  background: var(--surface-raised);
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--border-base);
}

.agenda-az-btn {
  font-size: var(--text-xs) !important;
  line-height: 1.5 !important;
  padding: 2px 7px !important;
  font-weight: 600;
  border: 1px solid transparent;
  color: var(--text-secondary);
  background: transparent;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.agenda-az-btn:hover {
  background: var(--surface-sunken);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.agenda-az-btn.has-contacts {
  color: var(--text-primary);
  font-weight: 700;
  border-color: var(--border-base);
  background: var(--surface-card);
}

.agenda-az-btn.active {
  background: var(--pont-dark) !important;
  color: var(--pont-gold) !important;
  border-color: var(--pont-dark) !important;
  font-weight: 800;
}

.agenda-avatar-box {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-raised);
  border: 1px solid var(--border-base);
  color: var(--text-primary);
  font-weight: 700;
  font-size: var(--text-xs);
}

@media (max-width: 767.98px) {
  .agenda-az-bar { padding: 0.4rem 0.5rem; gap: 2px; }
  .agenda-az-btn { font-size: 0.65rem !important; padding: 2px 5px !important; }
}

/* ==========================================================================
   E-MAIL — Módulo de envío masivo
   ========================================================================== */
.email-body-preview {
  max-height: 300px;
  overflow-y: auto;
  font-size: var(--text-base);
  line-height: 1.6;
  border: 1px solid var(--border-base);
  padding: 1rem;
  background: var(--surface-raised);
}

#email-body-editor {
  min-height: 180px;
  outline: none;
  font-size: var(--text-base);
  line-height: 1.6;
  padding: 1rem;
  background: var(--surface-card);
  transition: background var(--transition-fast);
}

/* ==========================================================================
   CAMPAÑAS — Cards y gestión
   ========================================================================== */
.campaign-card:hover {
  box-shadow: 0 4px 20px rgba(10,8,5,0.10) !important;
  border-color: var(--pont-gold) !important;
}

.campaign-card .progress {
  height: 4px;
  background-color: var(--border-base);
}

.campaign-card .progress-bar {
  transition: width 0.5s ease;
}

/* ==========================================================================
   LIQUIDACIÓN — Tablas e impresión
   ========================================================================== */
.liquidacion-table {
  font-size: var(--text-sm);
  border-collapse: collapse;
}

.liquidacion-table th {
  font-weight: 700;
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
  padding: 0.6rem 0.75rem;
}

.liquidacion-table td {
  vertical-align: middle;
  padding: 0.5rem 0.75rem;
}

.liquidacion-table tfoot tr td {
  font-weight: 700;
  background: var(--surface-raised);
  border-top: 2px solid var(--border-base);
  font-size: var(--text-base);
}

.liquidacion-total-row {
  background: var(--color-success-bg);
  border-top: 2px solid var(--color-success) !important;
}

.liquidacion-wrapper { padding: 0.5rem; }

/* ==========================================================================
   DASHBOARD HOME — Tablas responsive
   ========================================================================== */
@media (max-width: 767.98px) {
  .table-home-responsive {
    table-layout: fixed !important;
    width: 100% !important;
    margin-bottom: 0 !important;
  }
  .table-home-responsive th,
  .table-home-responsive td {
    padding: 0.5rem 0.35rem !important;
    vertical-align: middle !important;
  }
  .card-body > .table-responsive { overflow-x: hidden !important; }
  .table-home-responsive .btn-group {
    display: inline-flex;
    flex-wrap: nowrap;
  }
}

/* ==========================================================================
   PRINT — Reglas de impresión
   ========================================================================== */
@media print {
  body * { visibility: hidden; }
  #modal-root, #modal-root * { visibility: visible; }
  #modal-root {
    position: absolute;
    left: 0; top: 0;
    width: 100%;
    background: #ffffff !important;
  }
  .modal-dialog { max-width: 100% !important; margin: 0 !important; }
  .modal-content { border: none !important; box-shadow: none !important; }
  .modal-header, .modal-footer, .btn-no-print { display: none !important; }

  .coreui-sidebar, .coreui-header, .modal-header, .modal-footer,
  #btn-close, button, .btn, .alert, .badge.bg-secondary, [data-action] {
    display: none !important;
  }
  .modal { position: static !important; background: white !important; }
  .modal-body { padding: 0 !important; }
  .liquidacion-wrapper { padding: 2rem; font-size: 10pt; }
  .liquidacion-table { width: 100%; font-size: 9pt; }
  .liquidacion-table th, .liquidacion-table td { padding: 4px 8px; border: 1px solid #ccc !important; }
  .liquidacion-table thead { background: #333 !important; color: white !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table-bordered { border: 1px solid #ccc !important; }
  .table-bordered th, .table-bordered td { border: 1px solid #ccc !important; }
  h5, h6 { font-size: 11pt !important; }
  .badge { font-size: 8pt !important; }
  .text-muted { color: #555 !important; }
}

/* ==========================================================================
   MICROINTERACCIONES & UTILIDADES GLOBALES
   ========================================================================== */

/* Fade-in de vistas */
@keyframes fadeInView {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeInView 0.2s ease-out both;
}

/* Skeleton loader */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 400px 100%;
  animation: shimmer 1.4s infinite;
}

/* Focus visible global */
*:focus-visible {
  outline: 2px solid var(--pont-gold);
  outline-offset: 2px;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ==========================================================================
   OPTIMIZACIÓN DE UX/UI, ACCESIBILIDAD Y REDISEÑO SECTORIAL
   ========================================================================== */

/* 1. Tipografía y Arquitectura de Tablas (Puntos 7, 8, 11) */
.table, table {
  font-size: 14px !important;
  line-height: 20px;
}

.table th, table th {
  font-size: 12px !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  color: #475569 !important;
  padding: 8px 12px !important;
  background: var(--surface-raised) !important;
  border-bottom: 1px solid var(--border-base) !important;
  vertical-align: middle !important;
}

.table td, table td {
  padding: 8px 12px !important;
  font-size: 14px !important;
  line-height: 20px !important;
  vertical-align: middle !important;
  color: #0f172a;
}

/* Filas con niveles de 48px a 56px */
.table tbody tr {
  min-height: 48px;
}

.item-title-primary {
  font-size: 14px !important;
  font-weight: 700 !important;
  color: #0f172a !important;
  line-height: 20px;
}

.item-meta-secondary {
  font-size: 12px !important;
  color: #475569 !important;
  line-height: 18px;
}

/* Cifras tabulares y alineación numérica a la derecha */
.num-col, .th-num, .td-num {
  text-align: right !important;
  font-variant-numeric: tabular-nums !important;
  font-family: var(--font-mono), var(--font-sans);
}

/* 2. Áreas de pulsación táctil (Touch targets WCAG 2.2 AA - Min 32x32px) (Punto 9) */
.btn-action-sm, .table .btn-sm {
  min-width: 32px !important;
  height: 32px !important;
  padding: 0 8px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 14px !important;
  gap: 4px;
}

.btn-action-sm i, .table .btn-sm i {
  font-size: 16px !important;
}

/* Dropdown "Más acciones" */
.dropdown-menu .dropdown-item-danger {
  color: #dc2626 !important;
  border-top: 1px solid var(--border-base);
  margin-top: 4px;
  padding-top: 6px;
}
.dropdown-menu .dropdown-item-danger:hover {
  background: #fef2f2 !important;
  color: #991b1b !important;
}

/* 3. Badges de Contraste Accesible (WCAG 2.2 AA > 6:1) (Punto 21) */
.badge-vencido, .badge.bg-danger-subtle, .badge-status-danger {
  background: #fee2e2 !important;
  color: #991b1b !important;
  border: 1px solid #fca5a5 !important;
  font-weight: 700 !important;
}

.badge-activa, .badge-realizado, .badge.bg-success-subtle, .badge-status-success {
  background: #dcfce7 !important;
  color: #166534 !important;
  border: 1px solid #86efac !important;
  font-weight: 700 !important;
}

.badge-sms, .badge.bg-primary-subtle, .badge-status-info {
  background: #dbeafe !important;
  color: #1e40af !important;
  border: 1px solid #93c5fd !important;
  font-weight: 700 !important;
}

.badge-postal, .badge.bg-warning-subtle, .badge-status-warning {
  background: #fef3c7 !important;
  color: #92400e !important;
  border: 1px solid #fde047 !important;
  font-weight: 700 !important;
}

.badge-fecha-futura {
  background: #fef9c3 !important;
  color: #854d0e !important;
  border: 1px solid #fef08a !important;
  font-weight: 700 !important;
}

/* 4. Normalización de Formularios (Punto 14) */
.form-control, .form-select {
  height: 40px !important;
  font-size: 14px !important;
  padding: 0.45rem 0.75rem !important;
  border: 1px solid #cbd5e1 !important;
  background-color: #ffffff !important;
  color: #0f172a !important;
}

.form-control:focus, .form-select:focus {
  border-color: var(--pont-gold) !important;
  box-shadow: 0 0 0 3px rgba(184, 150, 46, 0.18) !important;
}

.form-label, label {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: #374151 !important;
  margin-bottom: 0.35rem !important;
}

.form-group-wrap {
  margin-bottom: 16px !important;
}

.form-section-wrap {
  margin-bottom: 24px !important;
}

/* Indicador textual de error de validación (Punto 20) */
.invalid-feedback-text {
  font-size: 12px !important;
  font-weight: 600 !important;
  color: #dc2626 !important;
  margin-top: 4px !important;
  display: block;
}

/* 5. Modales accesibles y uniformes (Puntos 16, 17, 18) */
.modal-header {
  padding: 1rem 1.25rem !important;
  background: #ffffff !important;
  border-bottom: 1px solid var(--border-base) !important;
}

.modal-body {
  padding: 1.25rem !important;
  max-height: calc(100vh - 180px) !important;
  overflow-y: auto !important;
}

.modal-footer {
  padding: 0.85rem 1.25rem !important;
  background: var(--surface-raised) !important;
  border-top: 1px solid var(--border-base) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 12px !important;
}

.modal-footer .btn-secondary {
  height: 40px !important;
  padding: 0 1.25rem !important;
  background: #ffffff !important;
  color: #475569 !important;
  border: 1px solid #cbd5e1 !important;
  font-weight: 600 !important;
  font-size: 14px !important;
}

.modal-footer .btn-primary {
  height: 40px !important;
  padding: 0 1.25rem !important;
  background: #0a0805 !important;
  color: #ffffff !important;
  border: none !important;
  font-weight: 700 !important;
  font-size: 14px !important;
}

.modal-footer .btn-primary:hover {
  background: #1f2430 !important;
}

/* Focus Trap outline */
.modal:focus {
  outline: none !important;
}

/* 6. Panel Anotaciones Drawer (Punto 2) */
.anotaciones-drawer {
  width: 320px;
  flex-shrink: 0;
  transition: all 0.25s ease;
}

.anotaciones-collapsed-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.anotaciones-collapsed-toggle:hover {
  background: var(--pont-gold-lighter);
  border-color: var(--pont-gold);
  color: #0f172a;
}

/* 7. Franja compacta de Agenda (Punto 5) */
.agenda-metrics-strip {
  min-height: 56px;
  max-height: 64px;
  background: #ffffff;
  border: 1px solid var(--border-base);
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.agenda-metric-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  background: var(--surface-raised);
  border: 1px solid var(--border-base);
  cursor: pointer;
  transition: all 0.15s ease;
}

.agenda-metric-chip:hover, .agenda-metric-chip.active {
  background: #0a0805;
  color: #ffffff;
  border-color: #0a0805;
}

.agenda-metric-chip .badge {
  font-size: 11px;
  padding: 2px 6px;
}

/* 8. Adaptabilidad Responsive < 900px y Ventana Dividida 624px (Punto 10) */
@media (max-width: 900px) {
  .table-responsive {
    overflow-x: auto !important;
  }
  
  .hide-on-compact {
    display: none !important;
  }

  .show-on-compact-stack {
    display: block !important;
  }

  .table td, .table th {
    padding: 8px 8px !important;
  }
  
  .anotaciones-drawer {
    width: 100% !important;
  }
}