/* ============================================================
   Gestión Edenred — Estilos globales
   ============================================================ */

:root {
  --primary:       #d0df00;
  --primary-dark:  #b0be00;
  --primary-light: #f5f8cc;
  --sidebar-bg:    #53565a;
  --sidebar-text:  #c4c6c9;
  --sidebar-hover: #3e4144;
  --sidebar-active:#d0df00;
  --bg:            #f4f6fb;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --success:       #22c55e;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #3b82f6;
  --radius:        8px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ── Layout ── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: width .25s ease;
}

/* Sidebar toggle button */
.sidebar-toggle {
  width: 26px; height: 26px;
  background: transparent;
  border: 1px solid #6b6f73;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.sidebar-toggle:hover { background: var(--primary); color: #2a2c2f; border-color: var(--primary); }

/* Collapsed state */
.sidebar.collapsed { width: 56px; }

.sidebar.collapsed .sidebar-logo {
  padding: 14px 0;
  justify-content: center;
}
.sidebar.collapsed .logo-content { display: none; }

.sidebar.collapsed .sidebar-section-title { display: none; }

.sidebar.collapsed .sidebar-item {
  padding: 10px 0;
  justify-content: center;
  gap: 0;
}
.sidebar.collapsed .sidebar-item .sidebar-label { display: none; }
.sidebar.collapsed .sidebar-item .icon { width: auto; font-size: 1.1rem; }

/* Tooltip on hover when collapsed */
.sidebar.collapsed .sidebar-item {
  position: relative;
}
.sidebar.collapsed .sidebar-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: #3e4144;
  color: #fff;
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: .75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  z-index: 200;
}
.sidebar.collapsed .sidebar-item:hover::after { opacity: 1; }

.sidebar.collapsed .sidebar-footer {
  padding: 12px 0;
  align-items: center;
}
.sidebar.collapsed .sidebar-user {
  justify-content: center;
  position: relative;
}
.sidebar.collapsed .sidebar-user-info { display: none; }
.sidebar.collapsed .sidebar-avatar {
  position: relative;
  cursor: default;
}
.sidebar.collapsed .sidebar-avatar::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: #3e4144;
  color: #fff;
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: .75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  z-index: 200;
}
.sidebar.collapsed .sidebar-avatar:hover::after { opacity: 1; }
.sidebar.collapsed .logout-link { width: 100%; display: flex; justify-content: center; }
.sidebar.collapsed .btn-logout {
  width: 36px; height: 36px;
  padding: 0; justify-content: center;
  border-radius: 50%;
}
.sidebar.collapsed .logout-link { position: relative; }
.sidebar.collapsed .logout-link::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: #3e4144;
  color: #fff;
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: .75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  z-index: 200;
}
.sidebar.collapsed .logout-link:hover::after { opacity: 1; }
.sidebar-logo {
  padding: 16px 14px 14px 20px;
  border-bottom: 1px solid #3e4144;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}
.sidebar-logo-img {
  height: 32px;
  width: auto;
  display: block;
}
.sidebar.collapsed .sidebar-logo-img {
  height: 22px;
}
.sidebar-logo .logo-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
}
.sidebar-logo .logo-sub {
  font-size: .75rem;
  color: var(--sidebar-text);
  margin-top: 2px;
}
.sidebar-logo .logo-badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
}

.sidebar-section {
  padding: 16px 0 4px;
}
.sidebar-section-title {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: #4b5563;
  padding: 0 20px 6px;
  text-transform: uppercase;
}

.sidebar-nav { flex: 1; }
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sidebar-text);
  font-size: .875rem;
  transition: background .15s, color .15s;
  cursor: pointer;
}
.sidebar-item:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-item.active { background: var(--primary); color: #2a2c2f; }
.sidebar-item .icon { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid #3e4144;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.sidebar-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .8rem; font-weight: 700;
  flex-shrink: 0;
}
.sidebar-user-info .name { font-size: .8rem; font-weight: 600; color: #fff; }
.sidebar-user-info .role { font-size: .7rem; color: var(--sidebar-text); }
.btn-logout {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 7px 10px;
  background: #3e4144; border: none;
  color: var(--sidebar-text); border-radius: var(--radius);
  font-size: .8rem; cursor: pointer; transition: background .15s, color .15s;
}
.btn-logout:hover { background: var(--primary); color: #2a2c2f; }

/* ── Main content ── */
.main {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .25s ease;
}
.sidebar-collapsed .main { margin-left: 56px; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1rem; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.page-content {
  padding: 24px 28px;
  flex: 1;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: .95rem; font-weight: 600; }
.card-body { padding: 20px; }

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; line-height: 1.2; }
.stat-sub { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.stat-card.primary { border-left: 4px solid var(--primary); }
.stat-card.success { border-left: 4px solid var(--success); }
.stat-card.warning { border-left: 4px solid var(--warning); }
.stat-card.info    { border-left: 4px solid var(--info); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  font-size: .8rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: all .15s;
  white-space: nowrap;
}
.btn-sm { padding: 4px 10px; font-size: .75rem; }
.btn-lg { padding: 10px 20px; font-size: .9rem; }
.btn-primary   { background: var(--primary);   color: #2a2c2f; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success   { background: var(--success);   color: #fff; }
.btn-success:hover { filter: brightness(.9); }
.btn-warning   { background: var(--warning);   color: #fff; }
.btn-warning:hover { filter: brightness(.9); }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-danger:hover { filter: brightness(.9); }
.btn-outline   { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-ghost     { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn:disabled  { opacity: .5; cursor: not-allowed; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: .7rem; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase;
}
.badge-success  { background: #dcfce7; color: #16a34a; }
.badge-warning  { background: #fef3c7; color: #b45309; }
.badge-danger   { background: #fee2e2; color: #dc2626; }
.badge-info     { background: #dbeafe; color: #2563eb; }
.badge-gray     { background: #f1f5f9; color: #64748b; }
.badge-active   { background: #dcfce7; color: #16a34a; }
.badge-blocked  { background: #fee2e2; color: #dc2626; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .825rem; }
th {
  text-align: left; padding: 10px 14px;
  font-size: .7rem; font-weight: 700; letter-spacing: .05em;
  color: var(--text-muted); text-transform: uppercase;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
.td-mono { font-family: 'Roboto Mono', 'Courier New', monospace; font-size: .8rem; }
.td-amount { font-weight: 700; font-family: monospace; }
.td-amount.positive { color: var(--success); }
.td-amount.negative { color: var(--danger); }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 5px; }
.form-control {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  font-size: .875rem;
}
.form-control:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(230,57,70,.1);
}
.form-control::placeholder { color: #b0bec5; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* ── Filters bar ── */
.filters-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.filters-bar .form-group { margin-bottom: 0; }
.filters-bar .form-label { font-size: .72rem; }
.filters-bar .form-control { font-size: .8rem; padding: 6px 10px; }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #53565a 0%, #3e4144 100%);
}
.login-card {
  background: var(--surface); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 40px; width: 380px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-img { max-width: 240px; width: 100%; height: auto; display: block; margin: 0 auto; }
.login-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 20px; }

/* ── Alerts ── */
.alert {
  padding: 10px 14px; border-radius: var(--radius);
  font-size: .825rem; margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 8px;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Modals ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface); border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%; max-width: 600px; max-height: 90vh;
  overflow-y: auto;
}
.modal-lg { max-width: 860px; }
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: .95rem; font-weight: 600; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.2rem; line-height: 1;
  padding: 4px; border-radius: 4px;
}
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── Upload zone ── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 32px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary); background: var(--primary-light);
}
.upload-zone input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.upload-icon { font-size: 2rem; margin-bottom: 8px; }
.upload-text { font-size: .85rem; color: var(--text-muted); }
.upload-text strong { color: var(--primary); }

/* ── Validación status ── */
.val-icon { font-size: 1.4rem; }
.val-valido   .val-icon { color: var(--success); }
.val-revisar  .val-icon { color: var(--warning); }
.val-invalido .val-icon { color: var(--danger); }
.val-pendiente .val-icon { color: var(--text-muted); }

/* ── Image preview ── */
.img-preview {
  max-width: 100%; max-height: 400px;
  border-radius: var(--radius); border: 1px solid var(--border);
}

/* ── Progress bar ── */
.progress { background: var(--border); border-radius: 20px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 20px; transition: width .3s; }

/* ── Spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }

/* ── Tooltips / info pairs ── */
.dl-grid {
  display: grid; grid-template-columns: auto 1fr;
  gap: 6px 16px; font-size: .825rem;
}
.dl-label { color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.dl-value { font-weight: 500; }

/* ── Pagination ── */
.pagination {
  display: flex; align-items: center; gap: 4px;
  padding: 14px 20px; border-top: 1px solid var(--border);
}
.page-btn {
  padding: 5px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface);
  font-size: .8rem; cursor: pointer; transition: all .15s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #2a2c2f; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Toast notifications ── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--text); color: #fff;
  padding: 10px 16px; border-radius: var(--radius);
  font-size: .825rem; box-shadow: var(--shadow-md);
  animation: slideIn .2s ease;
  max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Utilities ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: .8rem; }
.text-xs { font-size: .72rem; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.font-mono { font-family: 'Roboto Mono', monospace; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; justify-content: center; }
.hidden { display: none !important; }

/* ── Tabla ancha con columnas fiscales ── */
.table-wrap table { border-collapse: collapse; }
.table-wrap th, .table-wrap td { white-space: nowrap; }

/* Columna sticky izquierda en tablas anchas */
.table-wrap td:first-child,
.table-wrap th:first-child {
  position: sticky; left: 0; z-index: 2; background: var(--surface);
}
.table-wrap thead th:first-child { background: #f8fafc; z-index: 3; }

/* Estado de fila por color de comprobante */
tr.row-verde         { background: #f0fdf4 !important; }
tr.row-verde:hover   { background: #dcfce7 !important; }
tr.row-amarillo      { background: #fffbeb !important; }
tr.row-amarillo:hover{ background: #fef3c7 !important; }
tr.row-rojo          { background: #fef2f2 !important; }
tr.row-rojo:hover    { background: #fee2e2 !important; }

/* Headers ordenables */
th.sortable          { cursor: pointer; user-select: none; }
th.sortable:hover    { color: var(--primary); }
th.sortable.asc::after  { content: ' ▲'; font-size: .6rem; opacity: .7; }
th.sortable.desc::after { content: ' ▼'; font-size: .6rem; opacity: .7; }

/* Celda con discrepancia */
td.disc-rojo { color: var(--danger); font-weight: 600; }

/* Zona de drop de carga masiva */
#bulk-zone.drag-over { border-color: var(--primary); background: var(--primary-light); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar:not(.collapsed) { width: 200px; }
  .layout:not(.sidebar-collapsed) .main { margin-left: 200px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .sidebar:not(.collapsed) { transform: translateX(-100%); }
  .layout:not(.sidebar-collapsed) .main { margin-left: 0; }
}
