/* ═══════════════════════════════════════════════
   TESORERÍA – Design System
   ═══════════════════════════════════════════════ */

:root {
  --brand:        #1a56db;
  --brand-dark:   #1342b0;
  --brand-light:  #e8f0fe;
  --brand-subtle: #f0f4ff;
  --surface:      #ffffff;
  --bg:           #f0f2f8;
  --border:       #e2e6ed;
  --border-strong:#c8cdd6;
  --text:         #111827;
  --text-2:       #4b5563;
  --text-3:       #9ca3af;
  --green:        #065f46;
  --green-bg:     #d1fae5;
  --amber:        #92400e;
  --amber-bg:     #fef3c7;
  --red:          #991b1b;
  --red-bg:       #fee2e2;
  --radius:       8px;
  --radius-lg:    12px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow:       0 4px 20px rgba(0,0,0,.09), 0 1px 4px rgba(0,0,0,.05);
  --shadow-lg:    0 12px 40px rgba(0,0,0,.14), 0 4px 12px rgba(0,0,0,.06);
  --nav-h:        60px;
  font-family: 'Inter', system-ui, -apple-system, Arial, sans-serif;
}

/* ── Reset / Base ── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header / Nav ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header h1 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.4px;
  color: var(--brand);
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
  padding-right: 20px;
  border-right: 1px solid var(--border);
}

.header h1 a, .brand-link {
  color: var(--brand);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
  letter-spacing: -.4px;
}
.header h1 a:hover, .brand-link:hover {
  color: var(--brand-dark);
  text-decoration: none;
}
.header h1 a::before, .brand-link::before {
  content: '◆';
  font-size: 10px;
  opacity: .7;
}

.nav {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 0 16px;
  overflow-x: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }

.nav a {
  padding: 6px 11px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.nav a:visited { color: var(--text-2); }
.nav a:hover {
  background: var(--brand-light);
  color: var(--brand);
  text-decoration: none;
}
.nav a.active {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}
.nav a.active:hover {
  background: var(--brand-dark);
  color: #fff;
  text-decoration: none;
}
.nav a:active { opacity: .85; }

.nav-sep {
  width: 1px;
  height: 18px;
  background: var(--border-strong);
  margin: 0 5px;
  flex-shrink: 0;
  opacity: .6;
}

/* ── Layout ── */
.container {
  padding: 22px 24px;
  max-width: 1600px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.4px;
  margin: 0 0 18px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-3);
  margin: 24px 0 10px;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 14px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ── Row / Field ── */
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 140px; }
label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .45px;
}

/* ── Inputs ── */
input, select, textarea {
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,86,219,.10);
}
input:disabled { background: var(--bg); color: var(--text-3); }

/* ── Buttons ── */
button { cursor: pointer; font-family: inherit; }
.btn, button {
  padding: 7px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  transition: background .15s, border-color .15s, box-shadow .12s;
  line-height: 1.4;
}
.btn:hover, button:hover {
  background: var(--bg);
  border-color: var(--border-strong);
}

button.primary, .btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  font-weight: 600;
}
button.primary:hover, .btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  box-shadow: 0 2px 8px rgba(26,86,219,.25);
}
button.primary:disabled, .btn-primary:disabled { opacity: .5; cursor: not-allowed; }

/* ── Login ── */
.login-body { background: var(--bg); }
.login-main {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-title {
  margin: 0 0 8px;
  text-align: center;
  font-size: 15px;
}
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.btn-ghost, button.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--bg); }

.btn-danger { background: var(--red); color: #fff; border-color: var(--red); font-weight: 600; }
.btn-danger:hover { background: #7f1d1d; border-color: #7f1d1d; }

.btn-sm, button.btn-sm {
  padding: 4px 10px;
  font-size: 12.5px;
}

/* ── Table ── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 13px;
}
.table th {
  background: var(--bg);
  padding: 9px 11px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .55px;
  color: var(--text-2);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--brand-subtle); }
.table tbody tr:last-child td { border-bottom: none; }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .15px;
}
.badge.ok, .badge.validado     { background: var(--green-bg); color: var(--green); }
.badge.pending, .badge.pendiente { background: var(--amber-bg); color: var(--amber); }
.badge.error                   { background: var(--red-bg); color: var(--red); }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10,15,25,.50);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  backdrop-filter: blur(3px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 1000px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
}
.modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal header strong { font-size: 15px; font-weight: 700; }
.modal .content { padding: 18px; }
.modal .actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--surface);
}

/* ── Toolbar / Pager ── */
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.pager {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 0;
}

/* ── Sortable table headers ── */
.th-sort { user-select: none; cursor: pointer; }
.th-sort:hover { color: var(--brand); }
.th-sort .arrow { font-size: 10px; margin-left: 4px; color: var(--brand); }

/* ── Utilities ── */
.small  { font-size: 12px; color: var(--text-2); }
.error  { color: var(--red); font-size: 13px; }
.muted  { color: var(--text-3); }
.mono   { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: .92em; }
.neg    { color: var(--red); font-weight: 600; font-variant-numeric: tabular-nums; }
.pos    { color: var(--green); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Importar Extracto (modal steps) ── */
.imp-steps {
  display: flex;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 18px;
}
.imp-step {
  flex: 1;
  padding: 9px 12px;
  background: var(--bg);
  font-size: 12.5px;
  color: var(--text-3);
  text-align: center;
  font-weight: 500;
  border-right: 1px solid var(--border);
}
.imp-step:last-child { border-right: none; }
.imp-step.active { background: var(--brand); color: #fff; font-weight: 700; }
.imp-step.done   { background: var(--green-bg); color: var(--green); }

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--bg);
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--brand);
  background: var(--brand-subtle);
}
.dropzone input[type=file] { display: none; }

.hoja-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  overflow: hidden;
}
.hoja-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.hoja-header:hover { background: var(--brand-light); }
.hoja-body { padding: 14px; display: none; }
.hoja-body.open { display: block; }

.imp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.imp-table th {
  background: var(--bg);
  padding: 7px 9px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-2);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.imp-table td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.imp-table tr.dup-row { background: var(--amber-bg); }
.imp-table tr.skip-row { opacity: .35; }
.imp-neg { color: var(--red); font-weight: 600; }
.imp-pos { color: var(--green); font-weight: 600; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  font-weight: 600;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  transform: translateY(8px);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok  { background: var(--green-bg); color: var(--green); border: 1px solid #6ee7b7; }
.toast.err { background: var(--red-bg);   color: var(--red);   border: 1px solid #fca5a5; }

/* ── Searchable Select (combobox empresa) ── */
.ss-wrap {
  position: relative;
  min-width: 140px;
}
.ss-input {
  width: 100%;
  cursor: text;
}
.ss-list {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow-y: auto;
  z-index: 300;
  display: none;
}
.ss-list.open { display: block; }
.ss-item {
  padding: 7px 10px;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ss-item:hover { background: var(--brand-subtle); }
.ss-item.ss-active { background: var(--brand-light); color: var(--brand); font-weight: 600; }
.ss-item.ss-placeholder { color: var(--text-3); font-style: italic; }
.ss-item.ss-empty { color: var(--text-3); font-style: italic; cursor: default; }
.ss-item.ss-empty:hover { background: none; }

/* ── Collapsible filter section ("Más filtros") ── */
.filters-extra {
  display: none;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
}
.filters-extra.open { display: flex; }

.btn-filters-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn-filters-toggle:hover { background: var(--brand-light); border-color: var(--brand); }
.btn-filters-toggle .f-arrow { font-size: 9px; display: inline-block; transition: transform .2s; }
.btn-filters-toggle.open .f-arrow { transform: rotate(90deg); }

/* ── Index Dashboard ── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}
.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .2s, border-color .2s, transform .18s;
  box-shadow: var(--shadow-sm);
}
.dash-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--brand);
  transform: translateY(-3px);
  text-decoration: none;
}
.dash-icon { font-size: 24px; line-height: 1; }
.dash-label { font-size: 14px; font-weight: 700; color: var(--text); margin-top: 2px; }
.dash-desc  { font-size: 12px; color: var(--text-3); line-height: 1.5; }

/* ── Modo prueba ─────────────────────────────────────────────────────── */
.modo-test-badge {
  display: none;
  align-items: center;
  gap: 5px;
  background: #fef3c7;
  color: #92400e;
  border: 1.5px solid #fbbf24;
  padding: 3px 10px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  flex-shrink: 0;
  margin-left: 12px;
  white-space: nowrap;
}
body[data-modo-prueba="1"] .modo-test-badge {
  display: flex;
}
body[data-modo-prueba="1"] .header {
  border-bottom: 3px solid #fbbf24;
}
.btn-modo-toggle {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 13px;
  padding: 5px 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-2);
  white-space: nowrap;
  font-family: inherit;
}
.btn-modo-toggle:hover {
  background: var(--brand-light);
  border-color: var(--brand);
  color: var(--brand);
}
.btn-modo-toggle.active {
  background: #fef3c7;
  border-color: #fbbf24;
  color: #92400e;
}
.btn-modo-toggle.active:hover {
  background: #fde68a;
}
.sesion-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 12px;
}
.sesion-usuario {
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}
.btn-logout {
  font-size: 13px;
  padding: 5px 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-2);
  white-space: nowrap;
  font-family: inherit;
}
.btn-logout:hover {
  background: var(--red-bg);
  border-color: var(--red);
  color: var(--red);
}
.btn-seed-data {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fbbf24;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
}
.btn-seed-data:hover:not(:disabled) { background: #fde68a; }
.btn-seed-data:disabled { opacity: .6; cursor: not-allowed; }
.btn-limpiar-data {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid #fca5a5;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
}
.btn-limpiar-data:hover:not(:disabled) { background: #fecaca; }
.btn-limpiar-data:disabled { opacity: .6; cursor: not-allowed; }

.barra-modo-test {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fef3c7;
  border: 1.5px solid #fbbf24;
  border-radius: var(--radius);
  padding: 8px 14px;
  margin-bottom: 16px;
}
