/* Modal behavior: keep Bootstrap defaults to preserve focus/scroll UX. */

/* Global layout + typography */
body {
  font-family: "Source Serif 4", "Georgia", serif;
  background: radial-gradient(circle at top left, #f8f4ed 0%, #f2efe9 60%, #ece6db 100%);
  color: #1c1b1a;
  min-height: 100vh;
  position: relative;
}

body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  opacity: 0.16;
  z-index: 0;
  pointer-events: none;
}

body::before {
  width: 520px;
  height: 520px;
  background: var(--brand-secondary, #d97706);
  top: -220px;
  right: -140px;
}

body::after {
  width: 420px;
  height: 420px;
  background: var(--brand-accent, #0f766e);
  bottom: -180px;
  left: -140px;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -40px;
  z-index: 1050;
  background: #ffffff;
  color: var(--brand-primary, #1f2a44);
  border: 1px solid rgba(31, 42, 68, 0.25);
  border-radius: 10px;
  padding: 0.35rem 0.65rem;
  text-decoration: none;
}

.skip-link:focus {
  top: 0.75rem;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Bebas Neue", "Arial Narrow", sans-serif;
  letter-spacing: 0.02em;
}

main.container {
  background: #fffaf2;
  border-radius: 26px;
  padding: 2rem;
  box-shadow: 0 20px 40px rgba(31, 42, 68, 0.12);
  position: relative;
  z-index: 1;
}

@media (max-width: 768px) {
  main.container {
    padding: 1.25rem;
  }
}

/* Navbar responsive tweaks */
.navbar-brand img { max-height: 36px; max-width: 140px; }
.navbar-nav .nav-link { padding-right: 0.9rem; padding-left: 0.9rem; }
.navbar-dark.bg-dark {
  background-color: var(--brand-primary, #1f2a44) !important;
}
.navbar-dark .navbar-nav .nav-link {
  color: rgba(255, 255, 255, 0.85);
}
.navbar-dark .navbar-nav .nav-link:hover {
  color: #ffffff;
}
@media (max-width: 991.98px) { /* breakpoint lg */
  .navbar-nav .dropdown-menu { position: static; float: none; box-shadow: none; }
  main.container { margin-top: 1rem; }
}

/* Reusable table component */
.table-responsive.table-scroll {
  overflow-x: auto;
  overflow-y: visible;
}
.table-scroll-top {
  display: none;
  overflow-x: auto;
  overflow-y: hidden;
  height: 12px;
  margin-bottom: 0.35rem;
}
.table-scroll-top-inner {
  height: 1px;
}
@media (max-width: 768px) {
  .table-scroll-top.is-active {
    display: block;
  }
  .report-hub ~ .table-scroll-top.is-active,
  .report-hub .table-scroll-top.is-active,
  .report-hub + .table-scroll-top.is-active {
    height: 18px;
    margin-bottom: 0.45rem;
  }
  .report-hub .table-scroll-top.is-active::-webkit-scrollbar,
  .report-hub + .table-scroll-top.is-active::-webkit-scrollbar {
    height: 14px;
  }
  .report-hub .table-scroll-top.is-active::-webkit-scrollbar-thumb,
  .report-hub + .table-scroll-top.is-active::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--brand-primary, #1f2a44) 55%, #9ca3af);
    border-radius: 999px;
  }
  .report-hub .table-scroll-top.is-active::-webkit-scrollbar-track,
  .report-hub + .table-scroll-top.is-active::-webkit-scrollbar-track {
    background: #e5e7eb;
    border-radius: 999px;
  }
  .table-responsive {
    overflow-x: auto;
    overflow-y: visible;
  }
}

/* Tablas: cabecera sticky y hover suave */
.table-sticky thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8f9fa;
}
.table-hover tbody tr:hover {
  background-color: #f4f6f8;
}

/* Report tables: base mode */
.report-table {
  table-layout: fixed !important;
  width: 100%;
  min-width: var(--report-table-min-width, 100%);
  font-size: 0.9rem;
}
.report-table.report-table-unified {
  width: 100%;
  max-width: 100%;
  min-width: var(--report-table-min-width, 100%);
}
.report-table th,
.report-table td {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.report-table th:last-child,
.report-table td:last-child {
  overflow: visible;
  text-overflow: clip;
}
.report-table-actions-dropdown .table-col-dropdown,
.report-table-actions-dropdown .table-col-dropdown * {
  overflow: visible !important;
  text-overflow: clip !important;
}
.report-table .report-tight {
  font-size: 0.8em;
  white-space: nowrap;
}
.report-table .report-narrow {
  width: 6.5rem;
}
.report-table .report-idx {
  width: 2.25rem;
  text-align: center;
}
.report-table .report-date {
  width: 6rem;
}
.report-table .report-wide {
  width: 20rem;
}
.report-table .col-id { width: 4.5rem; }
.report-table .col-date { width: 8rem; }
.report-table .col-party { width: 18rem; }
.report-table .col-doc { width: 15rem; }
.report-table .col-money { width: 8.5rem; }
.report-table .col-state { width: 8.5rem; }
.report-table .col-actions { width: 9rem; }

/* Ventas + Retenciones report column tuning (moved from inline template CSS). */
.ventas-ret-main-table {
  width: 100% !important;
  min-width: 0 !important;
  table-layout: fixed !important;
}
.ventas-ret-main-table th,
.ventas-ret-main-table td {
  white-space: normal !important;
}
.ventas-ret-main-table th:nth-child(1),
.ventas-ret-main-table td:nth-child(1) {
  min-width: 2.8rem;
  width: 2.8rem;
}
.ventas-ret-main-table th:nth-child(2),
.ventas-ret-main-table td:nth-child(2) {
  min-width: 4.2rem;
  width: 4.2rem;
}
.ventas-ret-main-table th:nth-child(4),
.ventas-ret-main-table td:nth-child(4) {
  width: 16rem;
}
.ventas-ret-ret-table th:nth-child(3),
.ventas-ret-ret-table td:nth-child(3) {
  width: 15rem;
}
.ventas-ret-ret-table th:nth-child(4),
.ventas-ret-ret-table td:nth-child(4) {
  width: 18rem;
}

/* Resumen mensual report column tuning (moved from inline template CSS). */
.resumen-table {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
}
.resumen-table th {
  white-space: normal;
}
.resumen-table td {
  vertical-align: top;
}
.resumen-table td:nth-child(2),
.resumen-table td:first-child {
  white-space: normal;
}
.resumen-ventas-table th:first-child,
.resumen-ventas-table td:first-child {
  min-width: 5.4rem;
  width: 5.4rem;
}
.resumen-ventas-table th:nth-child(2),
.resumen-ventas-table td:nth-child(2) {
  min-width: 20rem;
  width: 20rem;
}
.resumen-ventas-table .text-end {
  min-width: 5.8rem;
}

/* Login form alignment */
.auth-login-form .form-label {
  display: block;
  font-weight: 700;
  color: #1f2a44;
  margin-bottom: 0.35rem;
}

.auth-login-form input[type="text"],
.auth-login-form input[type="password"],
.auth-login-form input[type="email"] {
  width: 100%;
  display: block;
  box-sizing: border-box;
  padding: 0.55rem 0.7rem;
  border: 1px solid #cfd8e3;
  border-radius: 0.45rem;
  background: #ffffff;
  color: #1f2937;
}

.auth-login-form input:focus {
  outline: none;
  border-color: #6ea6d6;
  box-shadow: 0 0 0 0.18rem rgba(53, 126, 189, 0.18);
}

.auth-login-form .btn {
  min-width: 170px;
}

.auth-password-wrap {
  position: relative;
}

.auth-password-wrap input[type="password"],
.auth-password-wrap input[type="text"] {
  padding-right: 2.9rem;
}

.auth-password-toggle {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  min-width: auto !important;
  padding: 0.24rem 0.5rem;
  line-height: 1;
}

/* Report identity block (shown in report routes) */
.report-identity-header {
  border: 1px solid #d7e0ea;
  background: #f8fbff;
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  color: #1f2d3d;
}

.report-identity-line {
  font-size: 0.9rem;
  line-height: 1.35;
}
.resumen-egresos-table th:nth-child(2),
.resumen-egresos-table td:nth-child(2) {
  min-width: 5.4rem;
  width: 5.4rem;
}
.resumen-egresos-table th:nth-child(3),
.resumen-egresos-table td:nth-child(3) {
  min-width: 20rem;
  width: 20rem;
}
.resumen-table td div {
  line-height: 1.25;
}
.resumen-table .text-end {
  min-width: 6.2rem;
  white-space: nowrap;
}
.resumen-card-title {
  white-space: nowrap;
}

.report-table-compact {
  min-width: 0;
  table-layout: fixed;
}
.report-table-compact th,
.report-table-compact td {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
.table-financial-wrap {
  overflow-x: auto;
}
.table-financial-wrap .report-table-financial,
.table-financial-wrap .report-table-mode-financial {
  min-width: 0 !important;
  table-layout: fixed !important;
}
.table-financial-wrap .report-table-financial th,
.table-financial-wrap .report-table-financial td,
.table-financial-wrap .report-table-mode-financial th,
.table-financial-wrap .report-table-mode-financial td {
  white-space: normal !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  vertical-align: middle;
}
.table-financial-wrap .report-table-financial th:nth-last-child(2),
.table-financial-wrap .report-table-financial th:last-child,
.table-financial-wrap .report-table-financial td:nth-last-child(2),
.table-financial-wrap .report-table-financial td:last-child,
.table-financial-wrap .report-table-mode-financial th:nth-last-child(2),
.table-financial-wrap .report-table-mode-financial th:last-child,
.table-financial-wrap .report-table-mode-financial td:nth-last-child(2),
.table-financial-wrap .report-table-mode-financial td:last-child {
  padding-left: 0.4rem;
  padding-right: 0.4rem;
}

/* Truncate mode: single-line with ellipsis on desktop. */
.report-table.report-table-truncate th,
.report-table.report-table-truncate td,
.report-table.report-table-mode-truncate th,
.report-table.report-table-mode-truncate td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile readability: allow multi-line cells even when truncate is enabled. */
@media (max-width: 768px) {
  .report-table {
    font-size: 0.82rem;
  }

  .report-table th,
  .report-table td {
    padding: 0.35rem 0.45rem;
  }

  .report-table.report-table-truncate th,
  .report-table.report-table-truncate td,
  .report-table.report-table-mode-truncate th,
  .report-table.report-table-mode-truncate td {
    white-space: normal;
  }

  .report-table.report-table-truncate .report-tight,
  .report-table.report-table-mode-truncate .report-tight {
    white-space: normal;
  }

  .report-table.report-table-truncate td > div,
  .report-table.report-table-truncate td > a,
  .report-table.report-table-truncate td > span,
  .report-table.report-table-mode-truncate td > div,
  .report-table.report-table-mode-truncate td > a,
  .report-table.report-table-mode-truncate td > span {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.report-list-small {
  font-size: 0.85rem;
}

/* Badges consistentes para estados */
.badge-success { background-color: #28a745; }
.badge-warning { background-color: #ffc107; color: #212529; }
.badge-danger { background-color: #dc3545; }

/* Brand-driven buttons and utilities */
.btn-primary {
  background-color: var(--brand-primary, #1f2a44);
  border-color: var(--brand-primary, #1f2a44);
}
.btn-primary:hover,
.btn-primary:focus {
  background-color: color-mix(in srgb, var(--brand-primary, #1f2a44) 85%, #000);
  border-color: color-mix(in srgb, var(--brand-primary, #1f2a44) 85%, #000);
}
.btn-outline-primary {
  color: var(--brand-primary, #1f2a44);
  border-color: var(--brand-primary, #1f2a44);
}
.btn-outline-primary:hover,
.btn-outline-primary:focus {
  background-color: var(--brand-primary, #1f2a44);
  border-color: var(--brand-primary, #1f2a44);
}
.btn-dark {
  background-color: var(--brand-primary, #1f2a44);
  border-color: var(--brand-primary, #1f2a44);
}
.btn-outline-dark {
  color: var(--brand-primary, #1f2a44);
  border-color: var(--brand-primary, #1f2a44);
}
.btn-outline-dark:hover,
.btn-outline-dark:focus {
  background-color: var(--brand-primary, #1f2a44);
  border-color: var(--brand-primary, #1f2a44);
}
.text-primary {
  color: var(--brand-primary, #1f2a44) !important;
}
.bg-primary {
  background-color: var(--brand-primary, #1f2a44) !important;
}

/* KPI cards and modules */
.kpi-card { color: #fff; }
.kpi-sales { background: linear-gradient(135deg, #0d6efd, #0b5ed7); }
.kpi-expenses { background: linear-gradient(135deg, #dc3545, #bb2d3b); }
.kpi-ar { background: linear-gradient(135deg, #fd7e14, #e5670e); }
.kpi-ap { background: linear-gradient(135deg, #20c997, #1aa179); }
.module-card .list-group-item { font-size: 0.9rem; }
.module-card .card-header { display: flex; align-items: center; gap: 0.5rem; }

/* Global component styling with brand colors */
.card {
  border-radius: 16px;
  border: 1px solid rgba(31, 42, 68, 0.08);
  box-shadow: 0 12px 24px rgba(31, 42, 68, 0.08);
}
.card-header {
  background: color-mix(in srgb, var(--brand-primary, #1f2a44) 10%, #ffffff);
  border-bottom: 1px solid rgba(31, 42, 68, 0.08);
  font-weight: 600;
}
.table thead th {
  background: color-mix(in srgb, var(--brand-primary, #1f2a44) 8%, #ffffff);
}
.table-dark {
  --bs-table-bg: var(--brand-primary, #1f2a44);
  --bs-table-color: #ffffff;
}
.badge.bg-success,
.badge.bg-warning,
.badge.bg-danger,
.badge.bg-info {
  font-weight: 600;
}
.alert {
  border-radius: 14px;
  border: 1px solid rgba(31, 42, 68, 0.1);
}
.alert-success {
  background: color-mix(in srgb, var(--brand-accent, #0f766e) 12%, #ffffff);
  border-color: color-mix(in srgb, var(--brand-accent, #0f766e) 30%, #ffffff);
}
.alert-info {
  background: color-mix(in srgb, var(--brand-primary, #1f2a44) 10%, #ffffff);
  border-color: color-mix(in srgb, var(--brand-primary, #1f2a44) 25%, #ffffff);
}
.alert-warning {
  background: color-mix(in srgb, var(--brand-secondary, #d97706) 12%, #ffffff);
  border-color: color-mix(in srgb, var(--brand-secondary, #d97706) 28%, #ffffff);
}
.alert-danger {
  background: color-mix(in srgb, #dc3545 10%, #ffffff);
  border-color: color-mix(in srgb, #dc3545 24%, #ffffff);
}
.errorlist {
  list-style: none;
  padding-left: 0;
  margin: 0.35rem 0 0;
  color: #dc3545;
  font-size: 0.9rem;
}
.errorlist li {
  margin: 0;
}
.field-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}
.field-badge.required {
  background: color-mix(in srgb, #dc3545 12%, #ffffff);
  color: #b02a37;
  border: 1px solid color-mix(in srgb, #dc3545 30%, #ffffff);
}
.field-badge.optional {
  background: color-mix(in srgb, var(--brand-primary, #1f2a44) 8%, #ffffff);
  color: var(--brand-primary, #1f2a44);
  border: 1px solid color-mix(in srgb, var(--brand-primary, #1f2a44) 20%, #ffffff);
}
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.filter-chips .badge {
  padding: 0.45rem 0.6rem;
  font-weight: 600;
}
.empty-state {
  padding: 1rem 0;
}
.empty-state .empty-title {
  font-weight: 600;
}
.empty-state .empty-actions {
  margin-top: 0.5rem;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.form-control,
.form-select {
  border-radius: 12px;
  border-color: rgba(31, 42, 68, 0.2);
  box-shadow: none;
}
.form-control:focus,
.form-select:focus {
  border-color: var(--brand-accent, #0f766e);
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--brand-accent, #0f766e) 25%, transparent);
}
.dropdown-menu {
  border-radius: 14px;
  border: 1px solid rgba(31, 42, 68, 0.1);
  box-shadow: 0 18px 30px rgba(31, 42, 68, 0.12);
}
.list-group-item.active {
  background-color: var(--brand-primary, #1f2a44);
  border-color: var(--brand-primary, #1f2a44);
}
.list-group-item {
  border-color: rgba(31, 42, 68, 0.08);
}
.list-group-item-action:hover {
  background-color: color-mix(in srgb, var(--brand-secondary, #d97706) 10%, #ffffff);
}
.pagination .page-link {
  color: var(--brand-primary, #1f2a44);
  border-radius: 10px;
}
.pagination .page-item.active .page-link {
  background-color: var(--brand-primary, #1f2a44);
  border-color: var(--brand-primary, #1f2a44);
}

/* Keyboard focus visibility across interactive controls */
.btn:focus-visible,
.nav-link:focus-visible,
.dropdown-item:focus-visible,
.page-link:focus-visible,
.report-action-btn:focus-visible,
.table a:focus-visible {
  outline: 2px solid var(--brand-accent, #0f766e);
  outline-offset: 2px;
  box-shadow: none !important;
}

.navbar-dark .navbar-nav .nav-link:focus-visible {
  color: #ffffff;
  text-decoration: underline;
}

/* Skeleton loading for chart */
.skeleton {
  position: relative;
  overflow: hidden;
  background: #e9ecef;
  border-radius: 0.35rem;
  min-height: 280px;
}
.skeleton::after {
  content: "";
  position: absolute;
  top: 0; left: -40%;
  width: 40%; height: 100%;
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,0.45), rgba(255,255,255,0));
  animation: shimmer 1.2s infinite;
}

/* Report hub */
.report-hub {
  --hub-bg: #f2efe9;
  --hub-ink: #1c1b1a;
  --hub-accent: var(--brand-secondary, #d97706);
  --hub-accent-2: var(--brand-accent, #0f766e);
  font-family: "Source Serif 4", "Georgia", serif;
  font-size: 0.9rem;
  color: var(--hub-ink);
  background: radial-gradient(circle at top left, #f8f4ed 0%, #f2efe9 60%, #ece6db 100%);
  border-radius: 28px;
  padding: 2.5rem;
  position: relative;
  overflow: hidden;
}

.report-hub::before,
.report-hub::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  opacity: 0.18;
  z-index: 0;
}

.report-hub::before {
  width: 420px;
  height: 420px;
  background: var(--brand-secondary, #f5c29a);
  top: -180px;
  right: -120px;
}

.report-hub::after {
  width: 360px;
  height: 360px;
  background: var(--brand-accent, #8ab6cf);
  bottom: -160px;
  left: -120px;
}

.report-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 2rem;
  align-items: center;
  margin-bottom: 2rem;
  position: relative;
  z-index: 1;
}

.report-kicker {
  font-family: "Bebas Neue", "Arial Narrow", sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--hub-accent);
}

.report-title {
  font-family: "Bebas Neue", "Arial Narrow", sans-serif;
  font-size: clamp(2rem, 3.4vw, 3rem);
  margin: 0.2rem 0 0.5rem;
}

.report-subtitle {
  max-width: 520px;
  font-size: 0.92rem;
}

.report-hero-card {
  background: var(--brand-primary, #1f1a16);
  color: #f6efe6;
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 18px 40px rgba(24, 18, 15, 0.2);
}

.report-hero-label {
  font-family: "Bebas Neue", "Arial Narrow", sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.675rem;
  margin-bottom: 0.7rem;
}

.report-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.report-hero-actions .btn {
  border-radius: 999px;
  font-weight: 500;
  font-size: 0.8125rem;
}

.report-hero-meta {
  font-size: 0.775rem;
  color: rgba(246, 239, 230, 0.75);
}

.btn-report {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  border-radius: 999px;
}

.btn-report.btn-outline-light {
  border-width: 1px;
}

.btn-list {
  padding: 0.4rem 0.85rem;
  font-size: 0.78rem;
  border-radius: 0.75rem;
}

.report-hub-tools {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.report-hub-search .form-control {
  border-radius: 12px;
  font-size: 0.84rem;
  min-height: 40px;
}

.report-hub-filters {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.report-hub-filters .btn {
  border-radius: 999px;
  font-size: 0.7rem;
  padding: 0.26rem 0.72rem;
}

.report-hub-filters .btn.is-active {
  background: var(--brand-primary, #1f2a44);
  color: #ffffff;
  border-color: var(--brand-primary, #1f2a44);
}

.report-hub-shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
}

.report-shortcuts-block {
  border: 1px solid rgba(62, 54, 40, 0.09);
  border-radius: 14px;
  background: #fffaf2;
  padding: 0.62rem 0.72rem;
}

.report-shortcuts-title {
  font-family: "Bebas Neue", "Arial Narrow", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  margin-bottom: 0.38rem;
}

.report-shortcuts-list {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.report-shortcut-pill {
  text-decoration: none;
  border: 1px solid rgba(31, 42, 68, 0.2);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.74rem;
  color: #1f2a44;
  background: #ffffff;
}

.report-shortcut-pill:hover {
  background: #eef4ff;
}

.report-shortcuts-empty {
  font-size: 0.74rem;
  color: #6b7280;
}

.date-range-form {
  margin-bottom: 0;
}

.date-range-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.date-range-field {
  flex: 1 1 240px;
  min-width: 200px;
}

.date-range-field .form-group {
  margin-bottom: 0;
}

.date-range-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dashboard-calendar th,
.dashboard-calendar td {
  padding: 0.2rem;
}

.dashboard-calendar .border.rounded {
  padding: 0.15rem 0.25rem;
}

.dashboard-calendar .badge {
  font-size: 0.6rem;
  padding: 0.15rem 0.3rem;
}

.dashboard-calendar .small {
  font-size: 0.7rem;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  align-items: stretch;
}

.report-card {
  background: #fffaf2;
  border: 1px solid rgba(62, 54, 40, 0.08);
  border-radius: 20px;
  padding: 1.4rem;
  box-shadow: 0 18px 32px rgba(48, 42, 34, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  animation: reportRise 0.6s ease forwards;
  opacity: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  height: 100%;
  container-type: inline-size;
}

.report-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--brand-primary, #1f2a44) 24%, rgba(62, 54, 40, 0.08));
  box-shadow: 0 22px 36px rgba(48, 42, 34, 0.11);
}

.report-card:nth-child(2) { animation-delay: 0.08s; }
.report-card:nth-child(3) { animation-delay: 0.16s; }
.report-card:nth-child(4) { animation-delay: 0.24s; }
.report-card:nth-child(5) { animation-delay: 0.32s; }
.report-card:nth-child(6) { animation-delay: 0.4s; }
.report-card:nth-child(7) { animation-delay: 0.48s; }
.report-card:nth-child(8) { animation-delay: 0.56s; }

.report-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.report-card.is-hidden {
  display: none;
}

.report-card h3 {
  font-family: "Bebas Neue", "Arial Narrow", sans-serif;
  font-size: 1.35rem;
  margin: 0;
}

.report-tag {
  background: color-mix(in srgb, var(--brand-secondary, #d97706) 16%, #fff);
  color: var(--brand-secondary, #d97706);
  font-size: 0.58rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.report-card p {
  font-size: 0.78rem;
  margin: 0;
}

.report-actions {
  display: grid;
  gap: 0.6rem;
  margin-top: 0;
}

.report-actions-stack {
  display: grid;
  gap: 0.6rem;
}

.report-actions .input-group .form-control {
  border-radius: 999px 0 0 999px;
}

.report-actions .input-group .btn {
  border-radius: 0 999px 999px 0;
  font-weight: 500;
}

.report-actions .input-group.report-input-solo .input-group-text {
  border: 0;
  border-left: 1px solid #0d5cb6;
  border-radius: 0;
  background: #135fb4;
  color: #ffffff;
  font-weight: 600;
}

.report-actions .input-group.report-input-solo .form-control {
  border: 0;
  border-radius: 0;
  background: #ffffff;
  color: #1f2937;
}

.report-actions .input-group.report-input-solo {
  border: 1px solid #9fb7d9;
  border-radius: 999px;
  overflow: hidden;
  background: #f8f9fa;
}

.report-actions .input-group .form-control,
.report-actions .input-group .form-select,
.report-actions .input-group .input-group-text,
.report-actions .input-group .btn {
  min-height: 42px;
  font-size: 0.74rem;
}

.report-actions > .btn {
  width: 100%;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.74rem;
}


.report-favorite-btn {
  border: 1px solid rgba(31, 42, 68, 0.2);
  background: #ffffff;
  color: #7b8794;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  line-height: 1;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.report-favorite-btn.is-favorite {
  color: #c77800;
  border-color: #e7ad59;
  background: #fff4e1;
}

.report-card-wide {
  grid-column: span 2;
}

@media (max-width: 768px) {
  .report-hub {
    padding: 1.5rem;
  }

  .report-hub-shortcuts {
    grid-template-columns: 1fr;
  }

  .report-card-wide {
    grid-column: span 1;
  }
}

@keyframes reportRise {
  from {
    transform: translateY(14px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Compact KPI cards for financial reports */
.report-kpi-card {
  border-radius: 12px;
}
.report-kpi-card .card-body {
  padding: 0.8rem 0.9rem;
}
.report-kpi-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 0.2rem;
}
.report-kpi-value {
  font-family: "Bebas Neue", "Arial Narrow", sans-serif;
  font-size: 1.7rem;
  line-height: 1.05;
  color: #1f2a44;
}
.report-kpi-card-accent {
  border-color: color-mix(in srgb, var(--brand-primary, #1f2a44) 28%, #ffffff);
  background: color-mix(in srgb, var(--brand-primary, #1f2a44) 4%, #ffffff);
}
@media (max-width: 768px) {
  .report-kpi-value {
    font-size: 1.45rem;
  }
  .report-kpi-label {
    font-size: 0.72rem;
  }
}

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Source+Serif+4:wght@400;600&display=swap');
@keyframes shimmer {
  100% { transform: translateX(250%); }
}

/* Mobile table readability hardening: avoid character-by-character wrapping. */
.report-table th,
.report-table td {
  overflow-wrap: break-word;
  word-break: normal;
}

@media (max-width: 768px) {
  .report-table {
    /* Prefer horizontal scroll over collapsing all columns into unreadable blocks. */
    table-layout: auto !important;
    min-width: max(100%, 860px) !important;
  }

  .report-table-actions-dropdown .table-col-dropdown,
  .report-table-actions-dropdown td:last-child {
    white-space: nowrap;
  }

  .report-table-actions-dropdown .dropdown-toggle {
    white-space: nowrap;
    padding: 0.25rem 0.55rem;
    font-size: 0.78rem;
  }
}

/* Dashboard KPI cards (mobile): keep totals visible and avoid clipping. */
.kpi-card .display-6 {
  margin: 0;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .kpi-card .card-body {
    display: grid !important;
    grid-template-columns: 1fr auto;
    gap: 0.55rem;
    align-items: center;
  }

  .kpi-card .display-6 {
    font-size: clamp(1.05rem, 5.2vw, 1.45rem);
  }

  .kpi-card .text-uppercase.small {
    font-size: 0.66rem !important;
    line-height: 1.2;
  }

  .kpi-card i.fas {
    font-size: 1.1rem !important;
    opacity: 0.8;
  }
}

/* Report hub CTA buttons: stronger hit area and reliable pointer/touch capture. */
.report-action-btn {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 42px;
  padding: 0.45rem 0.85rem;
  touch-action: manipulation;
  pointer-events: auto;
}

@media (max-width: 768px) {
  .report-action-btn {
    min-height: 46px;
    font-size: 0.86rem;
  }
}

.report-action-btn:hover,
.report-action-btn:focus,
.report-action-btn:focus-visible {
  background-color: var(--brand-primary, #1f2a44) !important;
  border-color: var(--brand-primary, #1f2a44) !important;
  color: #ffffff !important;
}

/* Table min-width variants kept in CSS to avoid style values in templates. */
.report-table.table-notification-list {
  min-width: 980px !important;
}

.report-table.table-automation-runs {
  min-width: 1320px !important;
}

.report-table.table-auditlog-list {
  min-width: 1100px !important;
}

.report-table.table-conciliacion-sesiones {
  min-width: 920px !important;
}

.report-table.table-venta-list { min-width: 1120px !important; }
.report-table.table-cliente-list { min-width: 980px !important; }
.report-table.table-cobro-list { min-width: 1220px !important; }
.report-table.table-categoria-gasto-list { min-width: 760px !important; }

.report-table.table-gasto-list { min-width: 980px !important; }
.report-table.table-suscripcion-list { min-width: 920px !important; }
.report-table.table-orden-venta-list { min-width: 980px !important; }
.report-table.table-compra-list { min-width: 1100px !important; }
.report-table.table-pago-list { min-width: 1200px !important; }
.report-table.table-compras-iva-main { min-width: 1280px !important; }
.report-table.table-compras-iva-ret { min-width: 980px !important; }
.report-table.table-iva-semestral-ventas { min-width: 980px !important; }
.report-table.table-iva-semestral-compras { min-width: 980px !important; }
