/* ============================================================
   style.css — Expedientes Aduaneros
   ============================================================ */

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

:root {
  --color-bg:         #f0f2f5;
  --color-surface:    #ffffff;
  --color-border:     #dde1e7;
  --color-border-lt:  #eaecf0;
  --color-primary:    #1a56db;
  --color-primary-dk: #1447c0;
  --color-danger:     #c81e1e;
  --color-warn:       #d97706;
  --color-success:    #046c4e;
  --color-text:       #111827;
  --color-text-muted: #6b7280;
  --color-head-bg:    #1e2a3a;
  --color-head-text:  #f9fafb;
  --color-row-alt:    #f8f9fb;
  --color-row-term:   #f0fdf4;
  --color-venc-past:  #fef2f2;
  --color-venc-soon:  #fffbeb;
  --radius:           6px;
  --shadow:           0 1px 4px rgba(0,0,0,.08);
  --shadow-md:        0 2px 10px rgba(0,0,0,.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- HEADER ---- */
.site-header {
  background: var(--color-head-bg);
  color: var(--color-head-text);
  padding: 0 24px;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 56px;
}
.site-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  margin-right: 8px;
}
.tabla-tabs {
  display: flex;
  gap: 0;
  align-self: stretch;
  align-items: stretch;
}
.tab {
  display: flex;
  align-items: center;
  padding: 0 18px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .03em;
  color: rgba(255,255,255,.65);
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
  text-decoration: none;
}
.tab:hover { color: #fff; text-decoration: none; }
.tab.active { color: #fff; border-bottom-color: #60a5fa; }

.btn-nuevo {
  margin-left: auto;
  background: var(--color-primary);
  color: #fff !important;
  padding: 7px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  text-decoration: none;
  transition: background .15s;
}
.btn-nuevo:hover { background: var(--color-primary-dk); text-decoration: none; }

/* ---- CONTAINER ---- */
.container {
  max-width: 1500px;
  margin: 24px auto;
  padding: 0 20px 60px;
}

/* ---- FILTROS ---- */
.filtros-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.filtros-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.filtro-group { display: flex; flex-direction: column; }
.filtro-busqueda { flex: 2 1 250px; }
.filtro-group:not(.filtro-busqueda):not(.filtro-narrow) { flex: 1 1 180px; }
.filtro-narrow { flex: 0 1 140px; }

.filtros-row input[type="search"],
.filtros-row input[type="text"],
.filtros-row input[type="number"],
.filtros-row select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  background: #fff;
  color: var(--color-text);
  height: 36px;
}
.filtros-row input:focus,
.filtros-row select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

.filtros-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn-filtrar {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.btn-filtrar:hover { background: var(--color-primary-dk); }
.btn-limpiar {
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--color-text-muted);
  background: #fff;
}
.btn-limpiar:hover { text-decoration: none; background: var(--color-bg); }
.resultado-count {
  margin-left: auto;
  font-size: 13px;
  color: var(--color-text-muted);
  font-weight: 600;
}

/* ---- ALERT / MSG ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
}
.alert-error   { background: #fef2f2; border: 1px solid #fca5a5; color: var(--color-danger); }
.alert-success { background: #f0fdf4; border: 1px solid #86efac; color: var(--color-success); }
.alert-eliminado {
  background: #fef2f2;
  border: 2px solid #ef4444;
  color: #991b1b;
  padding: 12px 18px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 14px;
}

/* ---- TABLE ---- */
.tabla-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}
.tabla-expedientes {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tabla-expedientes thead tr {
  background: var(--color-head-bg);
  color: var(--color-head-text);
}
.tabla-expedientes th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .04em;
  white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,.08);
}
.tabla-expedientes th a {
  color: rgba(255,255,255,.9);
  display: flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
}
.tabla-expedientes th a:hover { color: #fff; }
.sort-icon { font-size: 11px; opacity: .5; }
.sort-icon.active { opacity: 1; color: #93c5fd; }

.tabla-expedientes tbody tr {
  border-bottom: 1px solid var(--color-border-lt);
  transition: background .1s;
}
.tabla-expedientes tbody tr:nth-child(even) { background: var(--color-row-alt); }
.tabla-expedientes tbody tr:hover { background: #eef2ff; }
.tabla-expedientes tbody tr.row-terminado { background: var(--color-row-term); }
.tabla-expedientes tbody tr.row-terminado:hover { background: #dcfce7; }

.tabla-expedientes td {
  padding: 8px 12px;
  vertical-align: middle;
  max-width: 148px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.td-carpeta { font-weight: 600; color: var(--color-primary); }
.td-mono    { font-family: 'Consolas', 'Courier New', monospace; font-size: 12px; }
.td-bool    { text-align: center; }

.venc-pasado { background: #fef2f2 !important; color: var(--color-danger); font-weight: 600; }
.venc-proximo { background: #fffbeb !important; color: var(--color-warn); font-weight: 600; }

/* Badges */
.badge-si    { background: #dcfce7; color: #14532d; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-no    { background: #f1f5f9; color: #64748b; padding: 2px 8px; border-radius: 99px; font-size: 11px; }
.badge-warn  { background: #fef9c3; color: #713f12; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-tabla { background: #e0f2fe; color: #0369a1; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; margin-left: 8px; vertical-align: middle; }
.badge-terminado   { background: #dcfce7; color: #14532d; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; margin-left: 6px; }
.badge-warn-label  { background: #fef9c3; color: #713f12; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; margin-left: 6px; }

/* Action buttons in table */
.col-acciones { white-space: nowrap; text-align: center; width: 48px; }
.btn-accion {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
  transition: opacity .15s;
  opacity: .8;
}
.btn-ver       { font-size: 22px; }
.btn-restaurar { background: #dcfce7; }
.btn-accion:hover { opacity: 1; text-decoration: none; }
.btn-ver    { background: #e0f2fe; }
.btn-editar { background: #fef9c3; }
.btn-eliminar { background: #fef2f2; }

.sin-resultados {
  text-align: center;
  padding: 48px 20px;
  color: var(--color-text-muted);
  font-size: 15px;
}

/* ---- PAGINACIÓN ---- */
.paginacion {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.pag-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--color-text);
  transition: background .1s, border-color .1s;
}
.pag-btn:hover { background: #e8edf5; text-decoration: none; }
.pag-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.pag-ellipsis { padding: 0 6px; color: var(--color-text-muted); }
.pag-info {
  margin-left: 12px;
  color: var(--color-text-muted);
  font-size: 13px;
}

/* ---- FORM (nuevo / editar) ---- */
.form-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.form-header h2 {
  font-size: 20px;
  font-weight: 700;
  flex: 1;
}
.btn-volver {
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  background: #fff;
  color: var(--color-text);
  white-space: nowrap;
}
.btn-volver:hover { background: var(--color-bg); text-decoration: none; }
.btn-ver-detalle {
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  background: #fff;
}

.form-expediente { display: flex; flex-direction: column; gap: 20px; }

.form-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}
.form-section h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-head-bg);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border-lt);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.form-grid-nums { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-full { grid-column: 1 / -1; }
.req { color: var(--color-danger); }
.field-hint { display: block; font-size: 11px; font-weight: 400; color: var(--color-text-muted); text-transform: none; letter-spacing: 0; margin-top: 3px; }

.form-checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: flex-end;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}
.check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 0 10px;
}
.btn-guardar {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background .15s;
}
.btn-guardar:hover { background: var(--color-primary-dk); text-decoration: none; }
.btn-cancelar {
  padding: 10px 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  background: #fff;
  color: var(--color-text);
  text-decoration: none;
}
.btn-cancelar:hover { background: var(--color-bg); text-decoration: none; }
.btn-eliminar-link {
  color: var(--color-danger);
  border-color: #fca5a5;
}

/* ---- VER DETALLE ---- */
.detalle-actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
  align-items: center;
}
.detalle-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.detalle-section h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-head-bg);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border-lt);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.detalle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px 20px;
}
.detalle-importes { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.detalle-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.detalle-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.empty-val { color: var(--color-text-muted); font-style: italic; }
.mono { font-family: 'Consolas', monospace; font-size: 13px; }
.importe { font-weight: 600; font-size: 14px; }
.importe-pago { color: var(--color-success); }

.detalle-texto {
  font-size: 13px;
  line-height: 1.7;
  color: var(--color-text);
  white-space: pre-line;
  max-height: 300px;
  overflow-y: auto;
  background: #f8f9fb;
  border: 1px solid var(--color-border-lt);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.detalle-movimientos { max-height: 500px; }

/* ---- HISTORIAL DE CAMBIOS ---- */
.tabla-historial { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla-historial th { background: var(--color-bg-alt); font-weight: 600; padding: 8px 12px; text-align: left; border-bottom: 2px solid var(--color-border); }
.tabla-historial td { padding: 8px 12px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.tabla-historial tr:last-child td { border-bottom: none; }
.btn-ver-cambios { font-size: 12px; padding: 3px 10px; cursor: pointer; border: none; }

.modal-box--wide { min-width: min(700px, 90vw); max-width: 90vw; max-height: 80vh; overflow-y: auto; }
.modal-titulo { margin: 0 0 16px; font-size: 1rem; color: var(--color-text); }

.tabla-diff { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla-diff th { background: var(--color-bg-alt); font-weight: 600; padding: 8px 12px; text-align: left; border-bottom: 2px solid var(--color-border); }
.tabla-diff td { padding: 8px 12px; border-bottom: 1px solid var(--color-border); vertical-align: top; }
.tabla-diff tr:last-child td { border-bottom: none; }
.diff-campo   { font-weight: 600; color: var(--color-text); width: 28%; }
.diff-antes   { color: #b91c1c; background: #fef2f2; width: 33%; }
.diff-flecha  { color: var(--color-text-muted); text-align: center; width: 6%; }
.diff-despues { color: #166534; background: #f0fdf4; width: 33%; }
.diff-empty   { color: var(--color-text-muted); font-style: italic; }

/* ---- MODAL DE CONFIRMACIÓN ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 36px 44px;
  box-shadow: var(--shadow-md);
  text-align: center;
  min-width: 320px;
}
.modal-pregunta {
  font-size: 1.1rem;
  margin: 0 0 28px;
  color: var(--color-text);
}
.modal-acciones {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ---- TOAST / FLASH MSG ---- */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e2a3a;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 9999;
  transition: opacity .4s;
  display: none;
}
#toast.show { display: block; }

/* ---- LOGIN ---- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(145deg, #0d1b2e 0%, #1a3050 50%, #0f2240 100%);
}
.login-wrap {
  width: 100%;
  max-width: 500px;
  padding: 24px;
}
.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 48px 44px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.06);
}
.login-logo {
  background: var(--color-head-bg);
  border-radius: 10px;
  padding: 16px 24px;
  text-align: center;
  margin-bottom: 28px;
}
.login-logo img { height: 72px; display: block; margin: 0 auto; }
.login-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-head-bg);
  text-align: center;
  margin-bottom: 32px;
  letter-spacing: -.01em;
}
.login-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: -24px;
  margin-bottom: 28px;
}
.login-form { display: flex; flex-direction: column; gap: 20px; }
.login-form .form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  text-transform: none;
  letter-spacing: 0;
}
.login-form input {
  height: 44px;
  font-size: 14px;
  padding: 0 14px;
}
.login-btn {
  width: 100%;
  justify-content: center;
  padding: 13px;
  font-size: 15px;
  margin-top: 4px;
  border-radius: 8px;
  letter-spacing: .02em;
}

/* ---- HEADER USER INFO ---- */
.header-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: rgba(255,255,255,.75);
  white-space: nowrap;
}
.header-user strong { color: #fff; }
.btn-profile {
  color: rgba(255,255,255,.55) !important;
  font-size: 15px;
  line-height: 1;
  text-decoration: none;
  transition: color .15s;
}
.btn-profile:hover { color: #fff !important; text-decoration: none; }
.btn-logout {
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.85) !important;
  padding: 5px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.22); text-decoration: none; }

/* ---- ARCHIVOS ADJUNTOS ---- */
.adjuntos-tabla-wrapper {
  margin-bottom: 20px;
}
.tabla-adjuntos {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tabla-adjuntos thead tr {
  background: var(--color-head-bg);
  color: var(--color-head-text);
}
.tabla-adjuntos th {
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .04em;
  white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,.08);
}
.tabla-adjuntos tbody tr {
  border-bottom: 1px solid var(--color-border-lt);
}
.tabla-adjuntos tbody tr:nth-child(even) { background: var(--color-row-alt); }
.tabla-adjuntos tbody tr:hover { background: #eef2ff; }
.tabla-adjuntos td {
  padding: 8px 12px;
  vertical-align: middle;
}
.adjunto-link {
  font-weight: 500;
  word-break: break-all;
}
.adjunto-comentarios {
  max-width: 260px;
  color: var(--color-text-muted);
  font-size: 12px;
}
.adjunto-fecha { white-space: nowrap; color: var(--color-text-muted); font-size: 12px; }
.adjunto-size  { white-space: nowrap; color: var(--color-text-muted); font-size: 12px; text-align: right; }
.adjuntos-empty { padding: 12px 0; font-style: italic; }

.adjunto-upload {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--color-border-lt);
}
.adjunto-upload h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-head-bg);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 14px;
}
.adjunto-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.adjunto-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.adjunto-file-input {
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  background: #fff;
  width: 100%;
}
.btn-adjunto-submit {
  align-self: flex-start;
  padding: 9px 20px;
  font-size: 13px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .header-inner { gap: 10px; }
  .site-header h1 { font-size: 15px; }
  .tab { padding: 0 10px; font-size: 12px; }
  .filtros-row { flex-direction: column; }
  .filtro-busqueda, .filtro-group, .filtro-narrow { flex: 1 1 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .detalle-grid { grid-template-columns: 1fr; }
  .detalle-actions { flex-direction: column; }
  .form-header { flex-direction: column; align-items: flex-start; }
}
