/* Ensure [hidden] attribute always wins over element-level display rules */
[hidden] { display: none !important; }

/* Base color palette */
:root {
  --bg: #eef3ef;
  --card: #ffffff;
  --text: #1d2a24;
  --muted: #5f6f67;
  --border: #d9e5de;
  --primary: #0f4c3a;
  --primary-hover: #167a5b;
  --danger: #aa2e25;
  --danger-bg: #fbe6e4;
  --success: #1f7a3f;
  --shadow: rgba(12, 35, 26, 0.1);
  --field-height: 42px;
}

:root[data-theme="light"] {
  --bg: #eef3ef;
  --card: #ffffff;
  --text: #1d2a24;
  --muted: #5f6f67;
  --border: #d9e5de;
  --primary: #0f4c3a;
  --primary-hover: #167a5b;
  --danger: #aa2e25;
  --danger-bg: #fbe6e4;
  --success: #1f7a3f;
  --shadow: rgba(12, 35, 26, 0.1);
}

:root[data-theme="dark"] {
  --bg: #0b1220;
  --card: #111827;
  --text: #f9fafb;
  --muted: #a1a1aa;
  --border: rgba(148, 163, 184, 0.3);
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.2);
  --success: #34d399;
  --shadow: rgba(0, 0, 0, 0.25);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0b1220;
    --card: #111827;
    --text: #f9fafb;
    --muted: #a1a1aa;
    --border: rgba(148, 163, 184, 0.3);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.2);
    --success: #34d399;
    --shadow: rgba(0, 0, 0, 0.25);
  }
}

* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  margin: 0;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 24px;
}

main {
  width: 100%;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

header h1 {
  margin: 0;
  font-size: 1.4rem;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

nav button {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}

.nav-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-left {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-user {
  position: relative;
}

.user-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nav-item-content,
.theme-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nav-icon {
  width: 1em;
  text-align: center;
}

.caret {
  font-size: 0.8rem;
}

.dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  padding: 8px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 220px;
  z-index: 20;
}

.dropdown button {
  width: 100%;
  text-align: left;
}

.theme-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.92rem;
}

.theme-toggle-row input[type="checkbox"] {
  appearance: none;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 35%, transparent);
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
}

.theme-toggle-row input[type="checkbox"]::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s ease;
}

.theme-toggle-row input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.theme-toggle-row input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}

.password-section-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.password-section-actions button {
  width: auto;
  min-width: 150px;
}

.mobile-nav-menu {
  display: none;
}

.mobile-nav-item {
  display: flex;
  align-items: center;
  width: 100% !important;
  box-sizing: border-box !important;
  min-width: 0;
  margin-bottom: 4px;
  padding: 14px 16px !important;
  font-size: 1rem !important;
  min-height: 48px;
  text-align: left;
  border-radius: 6px;
}

.mobile-nav-menu + #nav-logout {
  margin-top: 4px;
  padding: 14px 16px !important;
  font-size: 1rem !important;
  min-height: 48px;
}

nav button:hover {
  background: color-mix(in srgb, var(--primary) 10%, var(--card));
}

nav button.nav-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 35%, transparent);
}

nav button.btn-whatsapp.nav-active {
  background: #1ebe5d;
  border-color: #1ebe5d;
}

nav button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

nav button.btn-whatsapp {
  background: #25d366;
  border-color: #25d366;
  color: #ffffff;
  font-weight: 700;
}

nav button.btn-whatsapp:hover {
  background: #1ebe5d;
  border-color: #1ebe5d;
}

.dropdown button.danger {
  border-color: var(--danger);
  color: var(--text);
  background: var(--danger-bg);
}

.dropdown button.danger .nav-icon,
.dropdown button.danger .nav-label {
  color: var(--danger);
}

/* Status colors */
.status {
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.status-pendiente {
  background: #fef3c7;
  color: #92400e;
}

.status-confirmada {
  background: #d1fae5;
  color: #065f46;
}

.status-parcial {
  background: #fef3c7;
  color: #92400e;
}

.status-cancelada {
  background: #fee2e2;
  color: #991b1b;
}

.view {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px var(--shadow);
  width: 100%;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: white;
  cursor: pointer;
  font-weight: 600;
}

.tab:hover {
  background: var(--primary-hover);
}

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
}

.tab-panel {
  margin-top: 12px;
}

.technical-status {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.technical-status-online {
  background: #dcfce7;
  color: #166534;
}

.technical-status-offline {
  background: #fee2e2;
  color: #991b1b;
}

.technical-status-degraded {
  background: #fef3c7;
  color: #92400e;
}

form {
  display: grid;
  gap: 12px;
  max-width: 520px;
}

.form-row-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* Improve layout for the remesas filter bar */
#remesa-filters {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

#remesa-filters button {
  justify-self: start;
  width: auto;
}

.filters-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.filters-panel > summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  list-style: none;
}

.filters-panel > summary::-webkit-details-marker {
  display: none;
}

.filters-panel > summary::after {
  content: "▾";
  float: right;
  color: var(--muted);
}

.filters-panel[open] > summary::after {
  content: "▴";
}

.filters-panel[open] form {
  margin-top: 10px;
}

@media (min-width: 681px) {
  .filters-panel {
    border: 0;
    padding: 0;
  }

  .filters-panel > summary {
    display: none;
  }

  .filters-panel > form {
    display: grid;
  }
}

/* Add spacing between cards and following content */
.card {
  margin-bottom: 18px;
}

.remesa-quick-actions {
  margin-bottom: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.kpi-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.kpi-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.section-separator {
  height: 1px;
  margin: 8px 0 22px;
  background: linear-gradient(90deg, transparent 0%, rgba(148, 163, 184, 0.55) 18%, rgba(148, 163, 184, 0.55) 82%, transparent 100%);
}

/* Subtle horizontal rule within a card, between content zones */
.audit-card-separator {
  height: 1px;
  margin: 10px 0;
  background: var(--border);
  opacity: 0.6;
}

/* Group label above a set of cards in Técnico */
.tech-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin: 0 0 8px 2px;
}

.subsection-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 16px;
}

.subsection-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--muted);
}

.filters-compact {
  max-width: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px 12px;
  align-items: end;
}

.filters-compact button.small {
  justify-self: start;
  margin-right: 0;
}

.inline-toggle-filter {
  margin-top: 10px;
}

.inline-toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.inline-toggle-button:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.inline-toggle-button[aria-pressed="true"] {
  background: rgba(37, 99, 235, 0.12);
  border-color: var(--primary);
  color: var(--primary);
}

tfoot th {
  background: var(--bg-alt, #f5f5f5);
  border-top: 2px solid var(--border);
  font-weight: 700;
}

#cierre-controls {
  max-width: none;
}

#cierre-status {
  margin-top: 10px;
}

.assign-checkbox-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  padding: 10px;
  max-height: 260px;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.assign-checkbox-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
}

.assign-checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

body[data-role="financiero"] #filter-remesero-label {
  display: none !important;
}

body[data-role="financiero"] #deduccion-cliente-label,
body[data-role="financiero"] #deduccion-filter-cliente-label,
body[data-role="financiero"] #deduccion-col-cliente {
  display: none !important;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  padding: 10px 12px;
  min-height: var(--field-height);
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
}

button {
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: var(--primary);
  color: white;
  font-weight: 600;
}

button:hover {
  background: var(--primary-hover);
}

button.secondary {
  background: rgba(14, 165, 233, 0.15);
  color: var(--text);
  border: 1px solid rgba(14, 165, 233, 0.35);
}

button.danger {
  background: var(--danger);
  color: white;
}

button.success {
  background: #22c55e;
  color: white;
}

button.warning {
  background: #999999;
  color: white;
}

button.small {
  padding: 6px 10px;
  font-size: 0.85rem;
  margin-right: 8px;
}

button.btn-icon {
  min-width: 24px;
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.btn-icon.btn-with-text {
  width: auto;
  min-width: 0;
  height: auto;
  padding: 6px 10px;
  gap: 6px;
  line-height: 1.1;
  white-space: nowrap;
}

button.btn-confirm-text {
  min-width: 104px;
  height: 28px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1;
}

button.btn-confirm-text .icon {
  font-weight: 800;
  font-size: 0.95em;
}

button.btn-confirm-text .label {
  font-size: 0.82rem;
}

/* Cuadre: balance confirmation button */
button.btn-cuadre {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 6px;
  cursor: pointer;
}

button.btn-cuadre:disabled {
  opacity: 0.65;
  cursor: default;
}

/* Cuadre: date sub-label under KPI value */
.kpi-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--muted, #6b7280);
  margin-top: 2px;
}

/* Saldo KPI box: stack value + button vertically */
.kpi-box-saldo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.panel-mobile-totals {
  display: none;
}

.panel-mobile-cards {
  display: none;
}

.panel-mobile-totals-title {
  margin: 12px 0 8px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, #6b7280);
}

.panel-mobile-totals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.panel-mobile-total-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(148, 163, 184, 0.08);
}

.panel-mobile-total-label {
  display: block;
  font-size: 0.76rem;
  color: var(--muted, #6b7280);
  margin-bottom: 4px;
}

.panel-mobile-total-value {
  display: block;
  font-size: 0.98rem;
}

.panel-mobile-entity-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  background: rgba(148, 163, 184, 0.08);
  gap: 8px;
}

.panel-mobile-entity-name {
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-mobile-entity-saldo {
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

button.btn-confirm {
  background: #16a34a;
  color: white;
}

button.btn-confirm:hover {
  background: #15803d;
}


button.btn-edit {
  background: #facc15;
  color: #333;
  font-weight: bold;
  border: 1px solid #eab308;
  min-width: 110px;
  padding: 0.4em 1.2em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  font-size: 1em;
}

button.btn-edit .icon {
  font-size: 1.1em;
}

button.btn-edit .label {
  white-space: nowrap;
}

button.btn-icon.btn-edit {
  min-width: 24px;
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 0.85rem;
}

/* Action buttons with visible label (icon + text) used in table rows */
button.btn-action-labeled {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  min-height: 36px;
  min-width: 0;
  width: auto;
  border-radius: 6px;
  margin-right: 4px;
}

button.btn-action-labeled .icon {
  font-size: 0.95em;
  flex-shrink: 0;
}

button.btn-action-labeled .label {
  line-height: 1.1;
}

button.btn-edit:hover {
  background: #fde047;
  color: #111;
}

button.btn-cancel {
  background: #dc2626;
  color: white;
}

button.btn-cancel:hover {
  background: #b91c1c;
}

.error {
  margin-top: 10px;
  color: var(--danger);
}

.info {
  margin-top: 10px;
  color: var(--success);
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.info-row:last-child {
  border-bottom: none;
}
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--danger-bg);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 6px;
  font-size: 0.9rem;
}

table th,
table td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

table th {
  background: rgba(148, 163, 184, 0.15);
}

table tbody tr:nth-child(odd) td {
  background: rgba(148, 163, 184, 0.04);
}

table tbody tr:nth-child(even) td {
  background: rgba(148, 163, 184, 0.1);
}

#panel-admin-remeseros-table tbody tr.panel-balance-positive td,
#panel-admin-cuentas-table tbody tr.panel-balance-positive td,
.panel-mobile-total-card.panel-balance-positive,
.panel-mobile-entity-card.panel-balance-positive {
  background: rgba(22, 163, 74, 0.18) !important;
}

#panel-admin-remeseros-table tbody tr.panel-balance-negative td,
#panel-admin-cuentas-table tbody tr.panel-balance-negative td,
.panel-mobile-total-card.panel-balance-negative,
.panel-mobile-entity-card.panel-balance-negative {
  background: rgba(220, 38, 38, 0.18) !important;
}

table tbody tr td:first-child {
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}

table tbody tr td:last-child {
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

table tbody tr.table-total-row td {
  background: rgba(37, 99, 235, 0.14);
  font-weight: 700;
}

#remesa-table tbody tr.remesa-row-cancelada td {
  color: #fee2e2;
}

#remesa-table tbody tr.remesa-row-confirmada td {
  color: #d1fae5;
}

[data-theme="light"] #remesa-table tbody tr.remesa-row-cancelada td,
[data-theme="light"] #liquidacion-table tbody tr.liquidacion-row-cancelada td,
[data-theme="light"] #deduccion-table tbody tr.deduccion-row-cancelada td {
  color: #991b1b;
}

[data-theme="light"] #remesa-table tbody tr.remesa-row-confirmada td,
[data-theme="light"] #liquidacion-table tbody tr.liquidacion-row-confirmada td,
[data-theme="light"] #deduccion-table tbody tr.deduccion-row-confirmada td {
  color: #065f46;
}

#remesa-table td.copyable-remesa-field {
  cursor: copy;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

#remesa-table td.copyable-remesa-field:hover {
  filter: brightness(1.08);
}

#remesa-table td.copyable-remesa-field.copied {
  background: rgba(22, 163, 74, 0.2);
  box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.55);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.copy-feedback-toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(15, 76, 58, 0.95);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  z-index: 1200;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.copy-feedback-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.copy-feedback-toast.is-error {
  background: rgba(170, 46, 37, 0.95);
}

.app-update-banner {
  position: fixed;
  top: 16px;
  right: 16px;
  max-width: min(420px, calc(100vw - 32px));
  display: none;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(37, 99, 235, 0.28);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.96);
  color: #f8fafc;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.28);
  z-index: 1400;
}

.app-update-banner.visible {
  display: flex;
}

.app-update-banner-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.app-update-banner-title {
  font-size: 0.92rem;
  font-weight: 700;
}

.app-update-banner-text {
  font-size: 0.82rem;
  color: rgba(248, 250, 252, 0.84);
}

.app-update-banner-actions {
  margin-left: auto;
  flex-shrink: 0;
}

.app-update-banner-actions button {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
}

.app-update-banner-actions button:hover {
  background: #1d4ed8;
}

:root[data-theme="dark"] .copy-feedback-toast {
  background: rgba(31, 122, 63, 0.95);
}

:root[data-theme="dark"] .copy-feedback-toast.is-error {
  background: rgba(185, 28, 28, 0.95);
}

:root[data-theme="light"] .app-update-banner {
  background: rgba(255, 255, 255, 0.98);
  color: #0f172a;
  border-color: rgba(37, 99, 235, 0.18);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.14);
}

:root[data-theme="light"] .app-update-banner-text {
  color: rgba(15, 23, 42, 0.72);
}

#remesa-table td.remesa-observation-cell {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

#remesa-table td.remesa-observation-cell:hover {
  filter: brightness(1.08);
}

#liquidacion-table tbody tr.liquidacion-row-cancelada td,
#deduccion-table tbody tr.deduccion-row-cancelada td {
  color: #fee2e2;
}

#liquidacion-table tbody tr.liquidacion-row-confirmada td,
#deduccion-table tbody tr.deduccion-row-confirmada td {
  color: #d1fae5;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-top: 12px;
  padding: 8px 0;
}

.pagination-info {
  font-size: 0.875rem;
  color: var(--text-secondary, #94a3b8);
}

.panel-version-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 0.78rem;
  opacity: 0.85;
}

@media (max-width: 900px) {
  .page {
    padding: 16px;
  }

  nav button {
    flex: 1 1 140px;
    min-width: 120px;
  }

  .admin-tabs {
    flex-direction: column;
    gap: 10px;
  }

  .tab {
    width: 100%;
  }

  #remesa-filters {
    grid-template-columns: 1fr;
  }

  #remesa-filters button {
    justify-self: stretch;
  }
}

@media (max-width: 680px) {
  body {
    padding: 16px;
  }

  /* Use full viewport width for key sections on mobile */
  #section-panel,
  #section-remesas {
    width: calc(100% + 32px);
    margin-left: -16px;
    margin-right: -16px;
  }

  #section-panel > h2,
  #section-remesas > h2 {
    padding: 0 16px;
  }

  .nav-main {
    align-items: flex-start;
  }

  .nav-left {
    display: none;
  }

  .nav-user {
    width: 100%;
  }

  .user-btn {
    width: 100%;
    justify-content: space-between;
    padding: 12px 14px !important;
    font-size: 1rem !important;
    min-height: 48px;
  }

  .dropdown {
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
    min-width: 0;
    padding: 12px;
    border-radius: 0 0 10px 10px;
    border-left: none;
    border-right: none;
    margin-top: 0;
  }

  .mobile-nav-menu {
    display: block;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }

  .filters-panel {
    padding: 8px 10px;
  }

  .filters-panel:not([open]) form {
    display: none;
  }

  #section-remesas #remesa-table thead {
    display: none;
  }

  #section-remesas #remesa-table thead,
  #section-remesas #remesa-table thead tr,
  #section-remesas #remesa-table thead th {
    display: none !important;
  }

  #section-panel #panel-admin-remeseros-table thead,
  #section-panel #panel-admin-remeseros-table thead tr,
  #section-panel #panel-admin-remeseros-table thead th,
  #section-panel #panel-admin-cuentas-table thead,
  #section-panel #panel-admin-cuentas-table thead tr,
  #section-panel #panel-admin-cuentas-table thead th {
    display: none !important;
  }

  /* Panel admin tables: hidden on mobile — individual cards shown instead */
  #section-panel #panel-admin-remeseros-table,
  #section-panel #panel-admin-cuentas-table {
    display: none !important;
  }

  #section-admin table thead,
  #section-admin table thead tr,
  #section-admin table thead th,
  #section-liquidaciones table thead,
  #section-liquidaciones table thead tr,
  #section-liquidaciones table thead th,
  #section-deducciones table thead,
  #section-deducciones table thead tr,
  #section-deducciones table thead th,
  #liquidaciones-parciales-table thead,
  #liquidaciones-parciales-table thead tr,
  #liquidaciones-parciales-table thead th,
  #deducciones-parciales-table thead,
  #deducciones-parciales-table thead tr,
  #deducciones-parciales-table thead th,
  #remesero-liquidaciones-parciales-table thead,
  #remesero-liquidaciones-parciales-table thead tr,
  #remesero-liquidaciones-parciales-table thead th,
  #financiero-deducciones-parciales-table thead,
  #financiero-deducciones-parciales-table thead tr,
  #financiero-deducciones-parciales-table thead th,
  #remesero-notif-duplicadas-table thead,
  #remesero-notif-duplicadas-table thead tr,
  #remesero-notif-duplicadas-table thead th,
  #admin-notif-duplicadas-table thead,
  #admin-notif-duplicadas-table thead tr,
  #admin-notif-duplicadas-table thead th,
  #financiero-notif-duplicadas-table thead,
  #financiero-notif-duplicadas-table thead tr,
  #financiero-notif-duplicadas-table thead th {
    display: none !important;
  }

  #section-panel #panel-admin-remeseros-table tfoot,
  #section-panel #panel-admin-remeseros-table tfoot tr,
  #section-panel #panel-admin-remeseros-table tfoot th,
  #section-panel #panel-admin-cuentas-table tfoot,
  #section-panel #panel-admin-cuentas-table tfoot tr,
  #section-panel #panel-admin-cuentas-table tfoot th {
    display: none !important;
  }

  .panel-mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
  }

  .panel-mobile-totals {
    display: block;
    margin-top: 12px;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  table {
    border: 0;
    border-spacing: 0;
  }

  tr {
    margin-bottom: 12px;
  }

  td {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
  }

  td::before {
    content: attr(data-label);
    font-weight: 600;
    margin-right: 8px;
    flex-shrink: 0;
  }

  /* Observation cell: allow text to wrap and expand downward on mobile */
  #remesa-table td.remesa-observation-cell {
    flex-direction: column;
    align-items: flex-start;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    max-width: none;
    word-break: break-word;
    gap: 4px;
  }

  #remesa-table td.remesa-observation-cell::before {
    margin-right: 0;
  }

  /* Admin panel section separators */
  #section-panel > .card {
    margin-bottom: 2.5rem;
    border-top: 3px solid var(--primary);
    padding-top: 1.5rem;
  }

  #section-panel > .card h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 0;
    color: var(--text);
  }
}

/* Password visibility toggle styles */
.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
}

.password-input-wrapper input {
  flex: 1;
  padding-right: 40px;
}

.password-toggle-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: color 0.2s ease;
  font-size: 1.2rem;
}

.password-toggle-btn .fa-solid {
  font-size: 1rem;
}

.password-toggle-btn.active {
  color: var(--primary);
}

.password-toggle-btn:hover {
  color: var(--primary);
}

.password-toggle-btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
