/* ============================================================
   SISTEMA DE DISEÑO - GESTIÓN DE CASOS
   Paleta: azules modernos con degradados elegantes
   ============================================================ */

:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-deeper: #1e3a8a;
  --primary-light:  #60a5fa;
  --primary-pale:   #dbeafe;
  --accent:         #0ea5e9;
  --accent-dark:    #0284c7;

  --bg-page:     #eef2ff;
  --bg-surface:  #ffffff;
  --bg-surface2: #f8fafc;
  --bg-header:   linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #0ea5e9 100%);
  --bg-sidebar:  linear-gradient(180deg, #0f172a 0%, #1e3a8a 100%);

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-on-dark:   #f1f5f9;

  --border:       #e2e8f0;
  --border-focus: #2563eb;

  --danger:  #ef4444;
  --danger-bg: #fef2f2;
  --success: #22c55e;
  --success-bg: #f0fdf4;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --info:    #0ea5e9;

  /* Status colors (keeping originals but refined) */
  --status-vencimiento: #ef4444;
  --status-urgente:     #f59e0b;
  --status-asignado:    #a78bfa;
  --status-descargado:  #22c55e;
  --status-prioridad:   #f97316;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-md: 0 6px 12px -2px rgba(0,0,0,0.1), 0 3px 6px -2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 20px -3px rgba(0,0,0,0.12), 0 4px 8px -2px rgba(0,0,0,0.06);
  --shadow-xl: 0 20px 40px -5px rgba(0,0,0,0.15), 0 8px 16px -4px rgba(0,0,0,0.08);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --transition: all 0.2s ease;
  --transition-slow: all 0.4s ease;

  --sidebar-width: 260px;
  --header-h: 52px;
}

/* ============================================================
   RESET Y BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem !important; }

p { margin-bottom: 0.5rem; font-size: 0.9rem; }

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

/* ============================================================
   CABECERA DE PÁGINA
   ============================================================ */
.page-header {
  background: var(--bg-header);
  color: var(--text-on-dark);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-md);
  min-height: var(--header-h);
}

.page-header h3 {
  color: #fff;
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

/* ============================================================
   SIDEBAR / BARRA
   ============================================================ */
.sidebar {
  height: 100%;
  width: 0;
  position: fixed;
  z-index: 10000;
  top: 0;
  left: 0;
  background: var(--bg-sidebar);
  overflow-x: hidden;
  overflow-y: auto;
  transition: width 0.35s cubic-bezier(0.4,0,0.2,1);
  padding-top: 60px;
  box-shadow: none;
}

.sidebar.open {
  width: var(--sidebar-width);
  box-shadow: var(--shadow-xl);
}

.sidebar a {
  padding: 10px 16px 10px 24px;
  text-decoration: none;
  font-size: 0.95rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  border-left: 3px solid transparent;
}

.sidebar a:hover {
  color: #e2e8f0;
  background: rgba(255,255,255,0.07);
  border-left-color: var(--primary-light);
  padding-left: 28px;
}

.sidebar .closebtn {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 28px;
  margin-left: 0;
  padding: 4px 10px;
  color: #94a3b8;
  border-left: none !important;
}

.sidebar .closebtn:hover {
  color: #e2e8f0;
  background: transparent;
  border-left-color: transparent !important;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 8px 16px;
}

/* Botón abrir sidebar */
.openbtn {
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-header);
  color: white;
  padding: 8px 14px;
  border: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: var(--shadow);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.openbtn:hover {
  transform: translateX(2px);
  box-shadow: var(--shadow-md);
}

#main { transition: margin-left 0.35s; padding: 0; }

/* ============================================================
   LAYOUT PRINCIPAL (DOS PANELES)
   ============================================================ */
.main-layout {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

.panel-casos {
  width: 32%;
  min-width: 260px;
  max-width: 420px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 2px 0 8px rgba(0,0,0,0.05);
}

.panel-movimientos {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-page);
  padding: 12px;
  gap: 8px;
}

.panel-casos .panel-header,
.panel-movimientos .panel-header {
  background: var(--bg-header);
  color: #fff;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

/* ============================================================
   CASOS - LISTA
   ============================================================ */
.casos-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface2);
  flex-shrink: 0;
}

.casos-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--bg-surface);
  transition: var(--transition);
  color: var(--text-primary);
}

.casos-search input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.casos-search input::placeholder { color: var(--text-muted); }

.casos-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.casos-list::-webkit-scrollbar { width: 5px; }
.casos-list::-webkit-scrollbar-track { background: transparent; }
.casos-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Select de casos (existente, estilizado) */
select#Usuarios {
  width: 100%;
  height: 100% !important;
  border: none;
  outline: none;
  padding: 0;
  background: var(--bg-surface);
  font-size: 0.875rem;
  color: var(--text-primary);
  resize: none !important;
}

select#Usuarios option {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-primary);
}

select#Usuarios option:hover,
select#Usuarios option:focus {
  background: var(--primary-pale);
  color: var(--primary-dark);
}

/* ============================================================
   CARDS / CONTENEDORES
   ============================================================ */
.card-modern {
  background: var(--bg-surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-modern .card-head {
  background: linear-gradient(90deg, var(--primary-deeper), var(--primary));
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-modern .card-body {
  padding: 14px 16px;
}

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  border-radius: var(--radius-sm) !important;
  font-weight: 500;
  font-size: 0.82rem;
  padding: 6px 14px;
  transition: var(--transition) !important;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: white !important;
}

.btn-primary:hover {
  background: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
  box-shadow: 0 4px 10px rgba(37,99,235,0.35) !important;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface2) !important;
  border-color: var(--border) !important;
  color: var(--text-secondary) !important;
}

.btn-secondary:hover {
  background: var(--primary-pale) !important;
  border-color: var(--primary-light) !important;
  color: var(--primary-dark) !important;
}

.btn-danger {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: white !important;
}

.btn-sm {
  padding: 4px 10px !important;
  font-size: 0.78rem !important;
}

.btn-xs {
  padding: 2px 8px !important;
  font-size: 0.75rem !important;
  border-radius: 4px !important;
}

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-control, .form-select, select, input[type="text"],
input[type="date"], input[type="password"], input[type="email"],
textarea {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  padding: 7px 11px !important;
  font-size: 0.875rem !important;
  color: var(--text-primary) !important;
  background: var(--bg-surface) !important;
  transition: var(--transition) !important;
  width: 100%;
}

.form-control:focus, .form-select:focus, select:focus,
input[type="text"]:focus, input[type="date"]:focus,
input[type="password"]:focus, textarea:focus {
  outline: none !important;
  border-color: var(--border-focus) !important;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12) !important;
}

label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 3px;
  display: inline-block;
}

/* ============================================================
   MODALES
   ============================================================ */
.modal {
  display: none;
  position: fixed;
  z-index: 50000;
  inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.show, .modal[style*="block"], .modal[style*="flex"] {
  display: flex !important;
}

.modal-dialog {
  width: 100%;
  max-width: 520px;
  margin: auto;
  animation: modalIn 0.22s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-lg) !important;
  border: none !important;
  box-shadow: var(--shadow-xl) !important;
  overflow: hidden;
}

.modal-header {
  background: var(--bg-header);
  color: white !important;
  padding: 14px 20px !important;
  border-bottom: none !important;
  border-radius: 0 !important;
}

.modal-header .modal-title {
  color: white !important;
  font-weight: 600;
  font-size: 1rem;
}

.modal-header .close, .modal-header .btn-close {
  color: rgba(255,255,255,0.8) !important;
  opacity: 1 !important;
  filter: none !important;
  text-shadow: none !important;
  font-size: 1.4rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 4px;
  transition: var(--transition);
}

.modal-header .close:hover { color: white !important; }

.modal-body {
  padding: 20px !important;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 12px 20px !important;
  border-top: 1px solid var(--border) !important;
  background: var(--bg-surface2);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg) !important;
}

/* ============================================================
   TABLAS
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th, td {
  padding: 8px 12px !important;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

thead th, tr:first-child td {
  background: linear-gradient(90deg, var(--primary-deeper), var(--primary-dark));
  color: white;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: none;
  white-space: nowrap;
}

tbody tr:hover td {
  background: var(--primary-pale);
  transition: var(--transition);
}

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

/* Status row colors */
tr.vencimiento td, td.vencimiento,
td[style*="rgb(226, 95, 95)"], td[style*="rgb(231, 75, 75)"] {
  background: #fef2f2 !important;
  border-left: 3px solid var(--danger) !important;
  color: #991b1b !important;
  font-weight: 500;
}

tr.urgente td, td.urgente,
td[style*="rgb(226, 224, 95)"] {
  background: #fffbeb !important;
  border-left: 3px solid var(--warning) !important;
  color: #78350f;
}

td[style*="rgb(72, 206, 72)"], td.descargado {
  background: #f0fdf4 !important;
  border-left: 3px solid var(--success) !important;
}

/* ============================================================
   PANEL FLOTANTE / DRAGGABLE
   ============================================================ */
.panel-flotante {
  position: absolute;
  z-index: 10000;
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  resize: both;
  display: none;
}

.panel-flotante .drag-header {
  background: var(--bg-header);
  color: white;
  padding: 12px 16px;
  cursor: move;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.panel-flotante .drag-header .close-btn {
  color: rgba(255,255,255,0.8);
  font-size: 1.3rem;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0 4px;
  line-height: 1;
  transition: var(--transition);
}

.panel-flotante .drag-header .close-btn:hover { color: white; }

/* ============================================================
   BANDEJA
   ============================================================ */
#Bandeja {
  left: 15px !important;
  top: 15px !important;
  width: min(1200px, 95vw) !important;
  height: min(600px, 85vh) !important;
  background: var(--bg-surface) !important;
  border: none !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-xl) !important;
  overflow: auto !important;
}

#Bandejaheader {
  background: var(--bg-header) !important;
  color: white !important;
  padding: 12px 16px !important;
  cursor: move;
  height: auto !important;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex !important;
  align-items: center;
  font-weight: 600;
}

#BandejaProveidos, #BandejaEscrito {
  padding: 16px !important;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ============================================================
   MENSAJES / ALERTAS
   ============================================================ */
.alert-flotante {
  position: absolute;
  z-index: 300000000;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
}

.alert-flotante.danger {
  background: rgba(239,68,68,0.92);
  color: white;
}

.alert-flotante.success {
  background: rgba(34,197,94,0.92);
  color: white;
}

#divMensaje {
  border-radius: var(--radius-xl) !important;
  box-shadow: var(--shadow-xl) !important;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 16px 20px !important;
}

#lblMensaje {
  font-size: 1rem !important;
  font-weight: 500;
}

/* ============================================================
   INFO DE CASO (cabecera de movimientos)
   ============================================================ */
.caso-info-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 0.82rem;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.caso-info-bar label, .caso-info-bar b {
  color: var(--text-primary);
  font-size: 0.82rem;
}

.caso-info-bar .badge-estado {
  background: var(--primary-pale);
  color: var(--primary-dark);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.caso-info-bar .badge-estado:hover {
  background: var(--primary);
  color: white;
}

/* ============================================================
   NUEVO MOVIMIENTO (área de carga)
   ============================================================ */
.nuevo-mov-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.nuevo-mov-bar input[type="date"],
.nuevo-mov-bar textarea,
.nuevo-mov-bar select {
  width: auto !important;
  min-width: 0;
}

.nuevo-mov-bar textarea {
  resize: vertical;
  min-height: 36px;
  max-height: 80px;
  flex: 1;
  min-width: 120px;
}

/* ============================================================
   TABLA DE MOVIMIENTOS
   ============================================================ */
.movimientos-container {
  flex: 1;
  overflow-y: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.movimientos-container::-webkit-scrollbar { width: 5px; }
.movimientos-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

#Movimientos_Caso { width: 100%; }

#Movimientos_Caso tr:first-child td {
  background: linear-gradient(90deg, var(--primary-deeper), var(--primary-dark)) !important;
  color: white;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#Movimientos_Caso tbody tr { cursor: pointer; }
#Movimientos_Caso tbody tr:hover td { background: var(--primary-pale) !important; }

/* ============================================================
   BOTONES DE ACCIÓN (panel de casos)
   ============================================================ */
.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface2);
  flex-shrink: 0;
}

/* ============================================================
   FILTRO PANEL
   ============================================================ */
#Filtro {
  background: rgba(15,23,42,0.5) !important;
  backdrop-filter: blur(4px);
}

/* ============================================================
   ETIQUETAS / CHIPS DE ESTADO
   ============================================================ */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  gap: 4px;
}

.chip-primary { background: var(--primary-pale); color: var(--primary-dark); }
.chip-danger  { background: var(--danger-bg); color: var(--danger); }
.chip-success { background: var(--success-bg); color: #15803d; }
.chip-warning { background: var(--warning-bg); color: #92400e; }

/* ============================================================
   SCROLLBAR GLOBAL
   ============================================================ */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   SPINNER / ESPERA
   ============================================================ */
#divEspera, #wait {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  background: rgba(255,255,255,0.85) !important;
  backdrop-filter: blur(6px);
  border-radius: var(--radius-lg) !important;
  padding: 24px !important;
  box-shadow: var(--shadow-xl) !important;
  z-index: 999999 !important;
  width: auto !important;
  height: auto !important;
  display: none;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #0ea5e9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  padding: 16px;
}

.login-card {
  background: rgba(255,255,255,0.97);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.3s ease;
}

.login-card .login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-card .login-logo h4 {
  font-size: 1.4rem;
  background: var(--bg-header);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-top: 12px;
}

.login-card .form-group { margin-bottom: 16px; }

.login-card .btn-primary {
  width: 100%;
  padding: 11px !important;
  font-size: 0.95rem !important;
  justify-content: center;
}

/* ============================================================
   RESPONSIVE - TABLET (max 900px)
   ============================================================ */
@media (max-width: 900px) {
  .panel-casos {
    width: 40%;
    min-width: 200px;
  }

  .panel-movimientos { padding: 8px; }

  .nuevo-mov-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .nuevo-mov-bar textarea { width: 100% !important; }
  .nuevo-mov-bar input[type="date"] { width: 100% !important; }
  .nuevo-mov-bar select { width: 100% !important; }
}

/* ============================================================
   RESPONSIVE - MÓVIL (max 640px)
   ============================================================ */
@media (max-width: 640px) {
  :root { --header-h: 48px; }

  .main-layout {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - var(--header-h));
  }

  .panel-casos {
    width: 100%;
    max-width: 100%;
    height: 45vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .panel-movimientos {
    width: 100%;
    height: auto;
    padding: 8px;
    overflow-y: auto;
  }

  .movimientos-container {
    max-height: 50vh;
  }

  body { overflow-y: auto !important; }

  .modal-dialog {
    max-width: 100%;
    margin: 0;
  }

  .modal { padding: 8px; align-items: flex-end; }

  .modal-content { border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important; }

  #Bandeja {
    width: 98vw !important;
    height: 80vh !important;
    left: 1vw !important;
    top: 10vh !important;
  }

  #BandejaProveidos, #BandejaEscrito {
    float: none !important;
    width: 100% !important;
  }

  .action-bar { gap: 4px; }

  table { font-size: 0.78rem; }
  th, td { padding: 6px 8px !important; }

  .caso-info-bar { gap: 6px; font-size: 0.78rem; }

  .sidebar { width: 0; }

  h3 { font-size: 1rem; }
}

/* ============================================================
   UTILIDADES
   ============================================================ */
.text-danger  { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }

.bg-primary-pale { background: var(--primary-pale) !important; }
.bg-surface      { background: var(--bg-surface) !important; }

.fw-600 { font-weight: 600; }
.fw-500 { font-weight: 500; }

.rounded-pill { border-radius: 50px !important; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-1 { gap: 4px; }
.flex-wrap { flex-wrap: wrap; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }

.w-100 { width: 100%; }

/* Corrige Bootstrap 4 remnants */
.modal-backdrop { z-index: 9000 !important; }

/* Animación de notificaciones inline */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.notify-anim { animation: fadeSlideIn 0.2s ease; }

/* Google Fonts import */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================================
   HEADERS DE PANELES FLOTANTES: texto y botón cierre
   Aplica a TODOS los elementos con ID que termina en "header"
   ============================================================ */

/* Forzar fondo degradado en TODOS los headers de paneles */
[id$="header"] {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #0ea5e9 100%) !important;
  color: white !important;
  padding: 12px 18px !important;
  height: auto !important;
  min-height: 48px;
  display: flex !important;
  align-items: center !important;
  gap: 10px;
  user-select: none;
  cursor: move;
}

/* Texto dentro de headers: siempre blanco */
[id$="header"] h1, [id$="header"] h2, [id$="header"] h3,
[id$="header"] h4, [id$="header"] h5, [id$="header"] h6,
[id$="header"] p, [id$="header"] span:not(.btn-icon),
[id$="header"] label {
  color: white !important;
  margin: 0 !important;
  font-size: 0.95rem !important;
  font-weight: 600 !important;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Botón × cierre dentro de headers: blanco, redondeado, elegante */
[id$="header"] .close,
[id$="header"] button.close,
[id$="header"] .btn-close {
  color: white !important;
  opacity: 1 !important;
  text-shadow: none !important;
  background: rgba(255, 255, 255, 0.18) !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
  border-radius: 8px !important;
  padding: 3px 10px !important;
  margin-left: auto !important;
  font-size: 1.3rem !important;
  line-height: 1.2 !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  backdrop-filter: blur(4px);
  flex-shrink: 0;
}

[id$="header"] .close:hover,
[id$="header"] button.close:hover,
[id$="header"] .btn-close:hover {
  background: rgba(255, 255, 255, 0.32) !important;
  border-color: rgba(255, 255, 255, 0.5) !important;
  color: white !important;
  transform: scale(1.08);
}

[id$="header"] .close span,
[id$="header"] button.close span {
  color: white !important;
  text-shadow: none !important;
  display: inline !important;
}

/* Border-radius superior del panel */
[id$="header"]:first-child {
  border-radius: 16px 16px 0 0 !important;
}

/* Botón cierre estándar para paneles flotantes */
.panel-close-btn {
  color: white !important;
  background: rgba(255, 255, 255, 0.18) !important;
  border: 1px solid rgba(255, 255, 255, 0.28) !important;
  border-radius: 8px !important;
  padding: 3px 11px !important;
  font-size: 1.1rem !important;
  line-height: 1.4 !important;
  cursor: pointer !important;
  margin-left: auto !important;
  flex-shrink: 0;
  transition: all 0.18s ease !important;
  backdrop-filter: blur(4px);
  font-family: inherit;
}

.panel-close-btn:hover {
  background: rgba(255, 255, 255, 0.35) !important;
  border-color: rgba(255, 255, 255, 0.55) !important;
  transform: scale(1.1);
}

/* ============================================================
   PANELES FLOTANTES GENÉRICOS (override inline styles legacy)
   Aplica a todos los paneles draggable con patrón #83b2d8
   ============================================================ */

/* Cabeceras de paneles flotantes con el color legacy */
[id$="header"][style*="#83b2d8"],
[id$="header"][style*="83b2d8"],
div[style*="background-color: #83b2d8"],
div[style*="background-color:#83b2d8"] {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #0ea5e9 100%) !important;
  color: white !important;
  height: auto !important;
  padding: 12px 18px !important;
  border-radius: 16px 16px 0 0 !important;
  font-weight: 600 !important;
  display: flex !important;
  align-items: center !important;
}

/* Contenedores de paneles flotantes con fondo gris legacy */
#Administrativos, #MostrarProveido, #divHonorarios,
#divListadoSentencias, #Plazo, #DVcuit, #Divobjetivos,
#divSubirSentencias, #divArchivar {
  position: fixed !important;
  background: #fff !important;
  border: none !important;
  border-radius: 16px !important;
  box-shadow: 0 25px 60px rgba(0,0,0,0.18), 0 8px 24px rgba(0,0,0,0.1) !important;
  overflow: auto;
  scrollbar-width: thin;
}

/* Headers de paneles por ID */
#Administrativosheader, #MostrarProveidoheader,
#divHonorariosheader, #Planheader, #DVcuitheader {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #0ea5e9 100%) !important;
  color: white !important;
  height: auto !important;
  padding: 12px 18px !important;
  border-radius: 16px 16px 0 0 !important;
  font-weight: 600 !important;
  display: flex !important;
  align-items: center !important;
}

/* Responsive paneles flotantes */
@media (max-width: 640px) {
  #Administrativos, #MostrarProveido, #divHonorarios {
    width: 98vw !important;
    height: 90vh !important;
    left: 1vw !important;
    top: 5vh !important;
  }
}

/* Subir Movimiento / Adjuntos */
#Adjuntos-Movimientos {
  border-radius: var(--radius-lg) !important;
  border: none !important;
  box-shadow: var(--shadow-xl) !important;
  background: #fff !important;
}

/* CUIT panel */
#DVcuit {
  left: 72px;
  top: 72px;
  width: min(430px, calc(100vw - 24px)) !important;
  height: auto !important;
  max-height: calc(100vh - 24px);
  overflow: hidden !important;
}

#DVcuit .modal-content {
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-xl) !important;
}

#DVcuit .drag-header {
  justify-content: space-between;
}

#DVcuit .cuit-panel-body,
#DVcuit .cuit-panel-footer {
  cursor: move;
}

#DVcuit input,
#DVcuit button {
  cursor: auto;
}

#DVcuit .drag-header h5 {
  color: white !important;
  margin: 0 !important;
}

.cuit-panel-body {
  padding: 18px;
}

.cuit-row {
  display: grid;
  grid-template-columns: 64px auto minmax(150px, 1fr) auto 54px;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.cuit-row span {
  color: var(--text-secondary);
  font-weight: 600;
}

#DVcuit input[type="text"] {
  width: 100% !important;
  text-align: center;
}

#DVcuit .cuit-full {
  background-color: rgb(190, 190, 190) !important;
  text-align: left;
}

.cuit-label {
  display: block;
  margin-bottom: 4px;
}

.cuit-panel-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface2);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  #DVcuit {
    left: 12px;
    top: 64px;
  }

  .cuit-row {
    grid-template-columns: 56px auto minmax(120px, 1fr) auto 48px;
  }
}

/* Carátula imprimible - NO aplicar estilos modernos */
@media print {
  * { background: white !important; color: black !important; box-shadow: none !important; }
  .sidebar, .page-header, .action-bar, .nuevo-mov-bar { display: none !important; }
  .panel-casos { display: none !important; }
  .panel-movimientos { width: 100% !important; }
}

/* Etiquetas de estado en tablas */
.NotaVencimiento > td:nth-child(3),
td.NotaVencimiento {
  background: #fef2f2 !important;
  border-left: 3px solid #ef4444 !important;
  color: #991b1b !important;
  font-weight: 500;
}

.NotaUrgente > td:nth-child(3),
td.NotaUrgente {
  background: #fffbeb !important;
  border-left: 3px solid #f59e0b !important;
  color: #78350f;
}

.NotaAsignada > td:nth-child(3),
td.NotaAsignada {
  background: #f5f3ff !important;
  border-left: 3px solid #7c3aed !important;
}

/* Fix: modales que usan display:none por defecto */
.modal[style*="display: none"],
.modal[style*="display:none"] {
  display: none !important;
}

.modal[style*="display: block"],
.modal[style*="display:block"] {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

/* Mejora tablas de datos generales */
.table-striped tbody tr:nth-of-type(odd) td {
  background: #f8fafc !important;
}



/* ===== MOBILE PANEL SWITCH ===== */
@media (max-width: 768px) {
  .mobile-hidden { display: none !important; }

  .mobile-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    top: var(--header-h) !important;
    z-index: 500 !important;
    width: 100vw !important;
    height: calc(100vh - var(--header-h)) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    background: var(--bg-page) !important;
    /* display:block anula el flex del panel-movimientos para que
       el contenido desborde normalmente y el scroll funcione */
    display: block !important;
  }

  /* sin límite de altura en mobile-fullscreen */
  .mobile-fullscreen .movimientos-container {
    max-height: none !important;
  }

  .mobile-back-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .mobile-back-btn {
    background: var(--primary-pale, #eff6ff);
    color: var(--primary-dark, #1d4ed8);
    border: 1px solid var(--primary-light, #93c5fd);
    border-radius: var(--radius, 8px);
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
  }

  .mobile-back-btn:active {
    background: var(--primary, #2563eb);
    color: white;
  }
}

/* ===== MARCA DE AGUA ===== */
.panel-movimientos {
  position: relative;
  left: auto !important;
}
.panel-movimientos::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('/Logo.png') center center / 340px auto no-repeat;
  opacity: 0.04;
  pointer-events: none;
  z-index: 0;
}
