/* ── VinCAI DESIGN SYSTEM ── */
:root {
  --bg:           #f8f7f5;
  --bg-white:     #ffffff;
  --bg-navy:      #1b2a4a;
  --bg-navy-deep: #132038;
  --bg-muted:     #f1f0ed;
  --text:         #1e2d4d;
  --text-secondary: #5a6a85;
  --text-tertiary:  #8e9db8;
  --text-on-navy:   #dce5f2;
  --text-on-navy-muted: #7a93b8;
  --accent:       #2563a8;
  --accent-light: #ddeaf8;
  --accent-text:  #1a4d8f;
  --gold:         #b8943a;
  --gold-bright:  #c9a84c;
  --gold-dark:    #9a7a2e;
  --gold-light:   #f7f0df;
  --border:       rgba(30,45,77,0.09);
  
  /* Status Colors */
  --status-paid-bg: #d1e7dd;
  --status-paid-txt: #0f5132;
  --status-partial-bg: #fff3cd;
  --status-partial-txt: #664d03;
  --status-diff-bg: #cff4fc;
  --status-diff-txt: #087990;
  --status-unpaid-bg: #f8d7da;
  --status-unpaid-txt: #842029;
  --status-gray-bg: #e2e3e5;
  --status-gray-txt: #41464b;

  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    16px;
  --radius-xl:    20px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Manrope', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 3rem;
}

/* ── NAVBAR ── */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 3rem;
  background: var(--bg-navy);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(7, 13, 30, 0.15);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.logo-svg {
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-logo-text-wrap {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.nav-logo-title {
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.nav-logo-title span {
  color: #ff9f43; /* Warm orange/gold CAI */
}

.nav-logo-sub {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: #54a0ff; /* FAGRIL S.A. bright blue */
  margin-top: 4px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-on-navy-muted);
}

.filter-group i {
  width: 16px;
  height: 16px;
}

.custom-select {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background-color: var(--bg-navy-deep);
  color: var(--text-on-navy);
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: all 0.15s;
}

.custom-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.select-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.nav-cta {
  background: linear-gradient(135deg, var(--bg-navy) 0%, var(--bg-navy-deep) 100%);
  color: var(--text-on-navy);
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--gold);
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: all 0.2s;
  font-family: 'Manrope', sans-serif;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 3px 10px rgba(27,42,74,0.15);
}

.nav-cta i {
  width: 14px;
  height: 14px;
}

.nav-cta:hover {
  background: linear-gradient(135deg, var(--accent) 0%, var(--bg-navy) 100%);
  border-color: var(--accent-light);
  transform: translateY(-1px);
}

/* ── ALERT BANNER ── */
.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-left: 5px solid var(--accent-text);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 2rem;
  color: var(--accent-text);
}

.alert-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.alert-content h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.alert-content p {
  font-size: 14px;
  opacity: 0.9;
}

.hidden {
  display: none !important;
}

/* ── HERO STATS ── */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.kpi-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.6rem;
  box-shadow: 0 4px 20px rgba(30,45,77,0.02);
  transition: all 0.25s ease;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(30,45,77,0.06);
}

.kpi-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.kpi-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
}

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  font-weight: 700;
}

.kpi-info h2 {
  font-size: clamp(15px, 1.4vw, 22px);
  font-weight: 800;
  color: var(--bg-navy);
  letter-spacing: -0.02em;
  width: 100%;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.kpi-subtext {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* KPI Variant Colors */
.kpi-card[data-kpi="invoiced"] .kpi-icon-wrap {
  background-color: var(--accent-light);
  color: var(--accent-text);
}
.kpi-card[data-kpi="collected"] .kpi-icon-wrap {
  background-color: #d1e7dd;
  color: #0f5132;
}
.kpi-card[data-kpi="pending"] .kpi-icon-wrap {
  background-color: #f8d7da;
  color: #842029;
}
.kpi-card[data-kpi="partners"] .kpi-icon-wrap {
  background-color: #e2dcf8;
  color: #4b2aa8;
}
.kpi-card[data-kpi="unreconciled"] .kpi-icon-wrap {
  background-color: #fff3cd;
  color: #664d03;
}

/* ── CONTENT SECTION & TABS ── */
.content-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 1px;
}

.tabs {
  display: flex;
  gap: 1.5rem;
}

.tab-btn {
  background: none;
  border: none;
  padding: 12px 6px;
  font-family: 'Manrope', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-btn i {
  width: 16px;
  height: 16px;
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background-color: var(--accent);
  border-radius: 999px;
  transform: scaleX(0);
  transition: transform 0.2s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
}

.tab-btn.active::after {
  transform: scaleX(1);
}

.search-bar-wrap {
  position: relative;
  max-width: 320px;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  width: 16px;
  height: 16px;
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--bg-white);
  color: var(--text);
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 500;
  outline: none;
  transition: all 0.2s;
}

#search-input:focus {
  border-color: var(--accent);
  background-color: var(--bg-white);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* Tab contents */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.2s ease-out;
}

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

/* ── TABLE CARD ── */
.table-card {
  background-color: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(30,45,77,0.01);
  margin-bottom: 1.5rem;
}

.table-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.table-header h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--bg-navy);
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-header h3 i {
  width: 18px;
  height: 18px;
}

.table-header .subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  width: 100%;
  margin-top: 4px;
}

.table-header.header-warning {
  border-top: 4px solid var(--gold);
}

.table-header.header-alert {
  border-top: 4px solid var(--accent);
}

.control-tab-actions {
  margin-bottom: 1.25rem;
}

.control-tab-hint {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 6px;
  max-width: 640px;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.legend-item {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

.status-paid { background-color: var(--status-paid-txt); }
.status-partial { background-color: var(--status-partial-txt); }
.status-diff { background-color: var(--status-diff-txt); }
.status-unpaid { background-color: var(--status-unpaid-txt); }

/* ── TABLE RESPONSIVE ── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

th {
  background-color: var(--bg-muted);
  color: var(--text-secondary);
  font-weight: 700;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 10.5px;
}

td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
}

tr:last-child td {
  border-bottom: none;
}

tr.invoice-row {
  cursor: pointer;
  transition: background-color 0.15s;
}

tr.invoice-row:hover {
  background-color: rgba(37,99,168,0.02);
}

th.num, td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

th.center, td.center {
  text-align: center;
}

.filter-row th {
  padding: 6px 10px 10px;
  text-transform: none;
  letter-spacing: normal;
  border-bottom: 1px solid var(--border);
}

.table-filter-input {
  width: 100%;
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--bg-white);
  color: var(--text);
}

.table-filter-input:focus {
  outline: none;
  border-color: var(--bg-navy);
}

.table-filter-select.custom-select {
  width: 100%;
  background-color: var(--bg-white);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
  text-transform: none;
}

.reclassify-select.custom-select {
  background-color: var(--bg-white);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
  text-transform: none;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge i {
  width: 12px;
  height: 12px;
}

.badge-paid {
  background-color: var(--status-paid-bg);
  color: var(--status-paid-txt);
}

.badge-partial {
  background-color: var(--status-partial-bg);
  color: var(--status-partial-txt);
}

.badge-diff {
  background-color: var(--status-diff-bg);
  color: var(--status-diff-txt);
}

.badge-unpaid {
  background-color: var(--status-unpaid-bg);
  color: var(--status-unpaid-txt);
}

.badge-gray {
  background-color: var(--status-gray-bg);
  color: var(--status-gray-txt);
}

.badge-class {
  border-radius: 4px;
  font-size: 10px;
}

.badge-class-comercial {
  background-color: var(--accent-light);
  color: var(--accent-text);
}

.badge-class-socio {
  background-color: #e2dcf8;
  color: #4b2aa8;
}

.badge-class-otro {
  background-color: #e2e3e5;
  color: #41464b;
}

/* Table Details Collapsible Row */
tr.details-row {
  background-color: #faf9f6;
  border-left: 3px solid var(--accent);
}

tr.details-row td {
  padding: 1.25rem 2rem;
  font-size: 12px;
}

.details-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.details-title {
  font-weight: 800;
  color: var(--bg-navy);
  font-size: 13px;
  margin-bottom: 4px;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.details-block {
  background-color: var(--bg-white);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius-md);
}

.details-block h4 {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 700;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.details-t-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
}

.details-t-item:last-child {
  margin-bottom: 0;
}

.note-input,
.mp-amount-input,
.mp-date-input,
.mp-note-input {
  font-family: 'Manrope', sans-serif;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--bg-white);
  color: var(--bg-navy);
}

.note-input:focus,
.mp-amount-input:focus,
.mp-date-input:focus,
.mp-note-input:focus {
  outline: none;
  border-color: var(--bg-navy);
}

/* BUTTONS */
.btn {
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn i {
  width: 14px;
  height: 14px;
}

.btn-primary {
  background-color: var(--accent);
  color: var(--bg-white);
}

.btn-primary:hover {
  background-color: var(--accent-text);
}

.btn-secondary {
  background-color: var(--bg-muted);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: var(--border);
}

.btn-danger-ghost {
  background: transparent;
  color: #b02a37;
  border: 1px solid rgba(176,42,55,0.2);
}

.btn-danger-ghost:hover {
  background-color: #f8d7da;
  border-color: #b02a37;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 11px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-link:hover {
  color: var(--accent-text);
}

/* ── GRID CONTROL (TAB 3) ── */
.grid-control {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 1100px) {
  .grid-control {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1300px) {
  .grid-control-3 {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* ── LOGIN SCREEN ── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-navy);
}

.login-card {
  background-color: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(7, 13, 30, 0.35);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 1.5rem;
}

.login-card h2 {
  font-size: 18px;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-card label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-top: 8px;
}

.login-card input {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: 'Manrope', sans-serif;
  font-size: 14px;
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-card button {
  margin-top: 1.25rem;
  padding: 10px;
  font-size: 13px;
}

.login-error {
  font-size: 12px;
  font-weight: 600;
  color: var(--status-unpaid-txt);
  margin-top: 8px;
}

/* ── NAV: usuario logueado ── */
.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 1.25rem;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}

#nav-username {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-on-navy);
}

/* ── FORMULARIOS DE CARGA (Upload / Usuarios) ── */
.upload-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 1.5rem 1.5rem;
}

.upload-form label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-top: 8px;
}

.upload-form input, .upload-form select {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
}

.upload-form input:focus, .upload-form select:focus {
  outline: none;
  border-color: var(--accent);
}

.upload-form button {
  margin-top: 1rem;
  align-self: flex-start;
}

/* ── MODAL ── */
.modal {
  position: fixed;
  inset: 0;
  background-color: rgba(19,32,56,0.5); /* backdrop */
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-out;
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  width: 100%;
  max-width: 580px;
  padding: 1.5rem;
}

.modal-content {
  background-color: var(--bg-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 10px 40px rgba(19,32,56,0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
  from { transform: translateY(12px) scale(0.97); }
  to { transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 800;
  color: var(--bg-navy);
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-tertiary);
  cursor: pointer;
}

.close-btn:hover {
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-info-block {
  background-color: var(--bg-muted);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.info-row strong {
  color: var(--text-secondary);
}

.info-row span {
  font-weight: 700;
  color: var(--text);
}

.payment-selection-section h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.payment-list-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-payment-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.15s;
  gap: 12px;
}

.modal-payment-item:last-child {
  border-bottom: none;
}

.modal-payment-item:hover {
  background-color: var(--bg-muted);
}

.modal-payment-item.selected {
  background-color: var(--accent-light);
  border-left: 4px solid var(--accent);
}

.modal-payment-item input[type="radio"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.payment-item-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-grow: 1;
}

.payment-item-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
}

.payment-item-bottom {
  font-size: 10px;
  color: var(--text-secondary);
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  background-color: var(--bg-muted);
}

/* ── LOADER SPINNER ── */
.loader-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(19,32,56,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.spinner-container {
  background-color: var(--bg-white);
  padding: 2rem 3rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(19,32,56,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top: 4px solid var(--gold);
  border-radius: 999px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner-container p {
  color: var(--text-secondary);
}

/* ── BRAND HERO (POWERPOINT DESIGN ACCORDING TO BRAND SLIDES) ── */
.brand-hero {
  background-color: var(--bg-navy);
  background-image: radial-gradient(circle, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 24px 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gold);
  padding: 2.5rem;
  color: var(--text-on-navy);
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(27,42,74,0.15);
}

.brand-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 600px 300px at 80% 20%, rgba(37,99,168,0.15), transparent);
  pointer-events: none;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-bright);
  background: rgba(184,148,58,0.1);
  border: 1px solid rgba(184,148,58,0.25);
  padding: 4px 12px;
  border-radius: 99px;
  margin-bottom: 1rem;
  font-weight: 700;
}

.brand-hero h1 {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
  color: var(--bg-white);
  position: relative;
  z-index: 1;
}

.brand-hero h1 em {
  font-style: normal;
  color: var(--gold-bright);
}

.brand-hero p {
  font-size: 13.5px;
  color: var(--text-on-navy-muted);
  max-width: 650px;
  line-height: 1.6;
  font-weight: 400;
  position: relative;
  z-index: 1;
}

/* ── MOBILE / TABLET RESPONSIVE STYLES (iOS/Android) ── */
@media (max-width: 900px) {
  .container {
    padding: 1.25rem 1.5rem;
  }
  
  nav {
    padding: 1rem 1.5rem;
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
    text-align: center;
  }
  
  .nav-logo {
    justify-content: center;
  }
  
  .nav-right {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
  }
  
  .filter-group {
    justify-content: space-between;
  }
  
  .nav-cta {
    justify-content: center;
  }
  
  .tab-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  
  .tabs {
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 6px;
    width: 100%;
    justify-content: flex-start;
  }
  
  .tab-btn {
    padding: 10px 12px;
    flex-shrink: 0;
  }
  
  .search-bar-wrap {
    max-width: 100%;
  }
  
  .brand-hero {
    padding: 1.75rem;
    text-align: center;
  }
  
  .brand-hero p {
    margin: 0 auto;
  }
}

@media (max-width: 600px) {
  .hero-stats {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .kpi-card {
    padding: 1.25rem;
  }
  
  th, td {
    padding: 10px 8px;
    font-size: 12px;
  }
  
  .badge {
    padding: 3px 6px;
    font-size: 10px;
  }
  
  .details-grid {
    grid-template-columns: 1fr;
  }
  
  .modal-dialog {
    padding: 8px;
  }
  
  .modal-content {
    border-radius: var(--radius-md);
  }
  
  .modal-header, .modal-body, .modal-footer {
    padding: 1rem;
  }
}

/* ── ENCABEZADO IMPRESO (solo visible en el PDF/impresión) ── */
.print-header {
  display: none;
}

.print-header h2 {
  font-size: 18px;
  color: var(--bg-navy);
  margin: 0 0 4px 0;
}

.print-header p {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}

/* ── VISTA DE IMPRESIÓN NATIVA (Cmd/Ctrl+P) ──
   Además del botón de arriba, si el usuario imprime directo con el
   atajo del navegador, estas reglas dejan la hoja prolija. */
@media print {
  nav,
  .brand-hero,
  #empty-state-banner,
  .tab-header .tabs,
  .search-bar-wrap,
  #download-pdf-btn,
  #download-invoices-csv-btn,
  .control-tab-actions,
  .filter-row,
  .loader-overlay,
  .modal {
    display: none !important;
  }

  .print-header {
    display: block;
    margin-bottom: 1rem;
  }

  .tab-content {
    display: none !important;
  }

  .tab-content.active {
    display: block !important;
  }

  .table-responsive {
    overflow-x: visible;
    width: 100%;
  }

  #invoices-table th:last-child, #invoices-table td:last-child,
  #transfers-table th:last-child, #transfers-table td:last-child,
  #diff-invoices-table th:last-child, #diff-invoices-table td:last-child,
  #unmatched-transfers-table th:last-child, #unmatched-transfers-table td:last-child {
    display: none;
  }

  /* table-layout: fixed obliga a que las columnas respeten el ancho de
     página en vez de estirarse con el nombre de cliente más largo (que
     es lo que las empujaba fuera de la hoja y las cortaba). */
  table {
    font-size: 9px;
    table-layout: fixed;
    width: 100%;
  }

  th, td {
    padding: 3px 5px;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  td div, td span {
    font-size: 9px !important;
  }

  #invoices-table th:nth-child(1), #invoices-table td:nth-child(1) { width: 26%; }
  #invoices-table th:nth-child(2), #invoices-table td:nth-child(2) { width: 10%; }
  #invoices-table th:nth-child(3), #invoices-table td:nth-child(3) { width: 15%; }
  #invoices-table th:nth-child(4), #invoices-table td:nth-child(4) { width: 15%; }
  #invoices-table th:nth-child(5), #invoices-table td:nth-child(5) { width: 15%; }
  #invoices-table th:nth-child(6), #invoices-table td:nth-child(6) { width: 19%; }

  #transfers-table th:nth-child(1), #transfers-table td:nth-child(1) { width: 8%; }
  #transfers-table th:nth-child(2), #transfers-table td:nth-child(2) { width: 17%; }
  #transfers-table th:nth-child(3), #transfers-table td:nth-child(3) { width: 13%; }
  #transfers-table th:nth-child(4), #transfers-table td:nth-child(4) { width: 22%; }
  #transfers-table th:nth-child(5), #transfers-table td:nth-child(5) { width: 12%; }
  #transfers-table th:nth-child(6), #transfers-table td:nth-child(6) { width: 12%; }
  #transfers-table th:nth-child(7), #transfers-table td:nth-child(7) { width: 16%; }

  #diff-invoices-table th:nth-child(1), #diff-invoices-table td:nth-child(1) { width: 30%; }
  #diff-invoices-table th:nth-child(2), #diff-invoices-table td:nth-child(2) { width: 17%; }
  #diff-invoices-table th:nth-child(3), #diff-invoices-table td:nth-child(3) { width: 17%; }
  #diff-invoices-table th:nth-child(4), #diff-invoices-table td:nth-child(4) { width: 17%; }
  #diff-invoices-table th:nth-child(5), #diff-invoices-table td:nth-child(5) { width: 19%; }

  #unmatched-transfers-table th:nth-child(1), #unmatched-transfers-table td:nth-child(1) { width: 12%; }
  #unmatched-transfers-table th:nth-child(2), #unmatched-transfers-table td:nth-child(2) { width: 32%; }
  #unmatched-transfers-table th:nth-child(3), #unmatched-transfers-table td:nth-child(3) { width: 36%; }
  #unmatched-transfers-table th:nth-child(4), #unmatched-transfers-table td:nth-child(4) { width: 20%; }

  .table-card {
    box-shadow: none;
    border: 1px solid #ccc;
  }

  tr {
    break-inside: avoid;
  }

  @page {
    size: A4 landscape;
    margin: 12mm;
  }
}
