/* ===== RESET ===== */
:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-sidebar: #1e293b;
  --color-sidebar-hover: #334155;
  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --color-border: #e5e7eb;
  --color-text: #111827;
  --color-muted: #64748b;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08);
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
}

body.app-ready .main {
  animation: pageEnter 0.18s ease-out both;
}

body.sidebar-navigating .main {
  opacity: 0;
  transform: translateY(6px);
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== LAYOUT ===== */
.wrapper {
  display: flex;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #172033 0%, #1e293b 56%, #111827 100%);
  color: #fff;
  padding: 20px 16px;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06), 12px 0 30px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 8px 10px 18px;
  margin-bottom: 8px;
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(226, 232, 240, 0.14);
}

.sidebar-brand:hover {
  color: #fff;
}

.sidebar-brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.28);
  flex: 0 0 42px;
}

.sidebar-brand-mark i {
  font-size: 20px;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-brand-text strong {
  font-size: 19px;
  font-weight: 800;
  line-height: 1.2;
}

.sidebar-brand-text small {
  margin-top: 2px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.sidebar-section {
  padding-top: 8px;
}

.sidebar-session {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(226, 232, 240, 0.12);
}

.sidebar-credit {
  margin: 12px 8px 0;
  padding-top: 12px;
  border-top: 1px solid rgba(226, 232, 240, 0.10);
  color: #94a3b8;
  text-align: center;
  font-size: 10px;
  line-height: 1.55;
}

.sidebar-credit span,
.sidebar-credit strong,
.sidebar-credit a {
  display: block;
}

.sidebar-credit strong {
  margin-top: 2px;
  color: #cbd5e1;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.sidebar-credit a {
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.2s ease;
}

.sidebar-credit a:hover {
  color: #93c5fd;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  color: #cbd5e1;
  min-height: 44px;
  padding: 11px 12px;
  border-radius: 12px;
  text-decoration: none;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 650;
  overflow: hidden;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-link i {
  width: 22px;
  color: #93c5fd;
  font-size: 17px;
  text-align: center;
  transition: color 0.2s ease;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transform: translateX(2px);
}

.sidebar-link:hover i {
  color: #bfdbfe;
}

.sidebar-link.active {
  background: rgba(37, 99, 235, 0.2);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(147, 197, 253, 0.18), 0 10px 24px rgba(15, 23, 42, 0.18);
}

.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: #60a5fa;
}

.sidebar-link.active i {
  color: #fff;
}

.sidebar-link-logout {
  color: #fecaca;
}

.sidebar-link-logout i {
  color: #fca5a5;
}

.sidebar-link-logout:hover {
  background: rgba(220, 38, 38, 0.14);
}

.sidebar-title {
  margin: 12px 10px 8px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mobile-menu-toggle,
.sidebar-overlay,
.sidebar-close {
  display: none;
}

/* ===== MAIN ===== */
.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 22px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

/* ===== TOPBAR ===== */
.topbar {
  background: var(--color-surface);
  padding: 18px 22px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.topbar h3 {
  color: var(--color-text);
  font-size: 22px;
  font-weight: 700;
}

.topbar small,
.topbar span {
  color: var(--color-muted);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-left: auto;
}

.notification-button {
  position: relative;
  width: 42px;
  height: 42px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.notification-button:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  box-shadow: var(--shadow-sm);
}

.notification-menu {
  position: relative;
}

.notification-icon::before {
  content: "\1F514";
  font-size: 18px;
  line-height: 1;
}

.notification-count {
  position: absolute;
  top: -3px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff !important;
  border: 2px solid #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
}

.notification-count.is-hidden {
  display: none;
}

.notification-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(360px, calc(100vw - 32px));
  max-height: min(460px, calc(100vh - 120px));
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 60;
}

.notification-menu.open .notification-dropdown {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.notification-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--color-border);
  background: #f8fafc;
}

.notification-dropdown-header strong {
  color: var(--color-text);
  font-size: 14px;
}

.notification-mark-all {
  border: 0;
  background: transparent;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 0;
}

.notification-mark-all:disabled {
  color: var(--color-muted);
  cursor: default;
}

.notification-list {
  max-height: min(400px, calc(100vh - 180px));
  overflow-y: auto;
}

.notification-item {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  text-decoration: none;
  border-bottom: 1px solid #eef2f7;
  background: #fff;
}

.notification-item:hover {
  background: #f8fafc;
}

.notification-item.is-unread {
  background: #eff6ff;
}

.notification-item.is-unread:hover {
  background: #dbeafe;
}

.notification-item-title {
  color: var(--color-text) !important;
  font-size: 14px;
  font-weight: 700;
}

.notification-item-message {
  color: #475569 !important;
  font-size: 13px;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}

.notification-item-date {
  color: var(--color-muted) !important;
  font-size: 12px;
}

.notification-empty {
  padding: 18px 14px;
  color: var(--color-muted);
  font-size: 14px;
  text-align: center;
}

.notification-dropdown-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--color-border);
  background: #fff;
  text-align: center;
}

.notification-dropdown-footer a {
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.notification-dropdown-footer a:hover {
  text-decoration: underline;
}

.notification-page-list {
  display: grid;
  gap: 12px;
}

.notification-page-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  background: #fff;
}

.notification-page-item.is-unread {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.notification-page-content {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.notification-page-title {
  color: var(--color-text);
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.notification-page-message {
  color: #475569;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.notification-page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--color-muted);
  font-size: 12px;
}

.notification-pagination {
  overflow: hidden;
}

.user-menu {
  position: relative;
}

.user-menu-toggle {
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: #fff;
  min-height: 46px;
  padding: 5px 10px 5px 5px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.user-menu-toggle:hover,
.user-menu.open .user-menu-toggle {
  border-color: #bfdbfe;
  background: #f8fafc;
  box-shadow: var(--shadow-md);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  color: #fff !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 120px;
}

.user-meta strong {
  max-width: 180px;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta small {
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1.25;
}

.user-menu-arrow {
  width: 8px;
  height: 8px;
  border-right: 2px solid #94a3b8;
  border-bottom: 2px solid #94a3b8;
  transform: rotate(45deg);
  margin: -4px 2px 0 0;
  transition: transform 0.2s ease;
}

.user-menu.open .user-menu-arrow {
  transform: rotate(225deg);
  margin-top: 4px;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 1100;
  width: 190px;
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-md);
  display: none;
}

.user-menu.open .user-dropdown {
  display: block;
}

.user-dropdown a {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--color-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.user-dropdown a:hover {
  background: #f1f5f9;
}

/* ===== CARDS ===== */
.card {
  background: var(--color-surface);
  padding: 22px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.card h4 {
  color: var(--color-text);
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
}

.card p {
  color: var(--color-muted);
  line-height: 1.55;
}

/* ===== GRID ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

/* ===== KPI ===== */
.kpi {
  font-size: 24px;
  font-weight: bold;
}

.kpi-label {
  font-size: 13px;
  color: #888;
}

/* ===== TABLE ===== */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  padding: 13px 14px;
  font-size: 13px;
  color: #475569;
  background: #f8fafc;
  border-bottom: 1px solid var(--color-border);
  font-weight: 700;
}

.table td {
  padding: 14px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: middle;
  color: var(--color-text);
  font-size: 14px;
}

.table tr:hover {
  background: #f8fafc;
}

.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.historial-table-wrap {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.historial-event-table {
  min-width: 960px;
  table-layout: fixed;
}

.historial-event-table th:nth-child(1),
.historial-event-table td:nth-child(1) {
  width: 125px;
}

.historial-event-table th:nth-child(2),
.historial-event-table td:nth-child(2) {
  width: 190px;
}

.historial-event-table th:nth-child(3),
.historial-event-table td:nth-child(3),
.historial-event-table th:nth-child(4),
.historial-event-table td:nth-child(4) {
  width: 120px;
}

.historial-event-table th,
.historial-event-table td {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ===== BUTTONS ===== */
.btn {
  min-height: 38px;
  padding: 9px 15px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  line-height: 1.2;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.16);
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.attachment-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.attachment-delete-form {
  margin: 0;
}

.attachment-action-btn {
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.attachment-action-btn i {
  display: block;
  line-height: 1;
}

.confirm-dialog {
  width: min(92vw, 440px);
  padding: 28px;
  border: 0;
  border-radius: 16px;
  color: var(--color-text);
  text-align: center;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.confirm-dialog::backdrop {
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(3px);
}

.confirm-dialog-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fee2e2;
  color: #dc2626;
  font-size: 26px;
}

.confirm-dialog h4 {
  margin: 0 0 10px;
  font-size: 21px;
}

.confirm-dialog p {
  margin: 0;
  color: #64748b;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.confirm-dialog-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
}

@media (max-width: 480px) {
  .attachment-table {
    min-width: 720px;
  }

  .attachment-actions {
    gap: 10px;
  }

  .attachment-action-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  .confirm-dialog {
    padding: 22px 18px;
  }

  .confirm-dialog-actions {
    flex-direction: column-reverse;
  }

  .confirm-dialog-actions .btn {
    width: 100%;
  }
}

/* ===== FORM ===== */
.input-group {
  margin-bottom: 16px;
}

.input-group label {
  font-size: 13px;
  display: block;
  margin-bottom: 7px;
  color: #475569;
  font-weight: 600;
}

.input-group input,
.input-group select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid #d1d5db;
  background: #fff;
  color: var(--color-text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.input-group .checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 5px;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 600;
}

.input-group .checkbox-field input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  height: 18px;
  padding: 0;
  flex: 0 0 18px;
}

.input-group small {
  display: block;
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1.4;
}

.input-group textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid #d1d5db;
  background: #fff;
  color: var(--color-text);
  outline: none;
  resize: vertical;
}

.alert {
  padding: 11px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 600;
}

.alert-danger {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.despacho-form {
  max-width: 760px;
}

.autocomplete-field {
  position: relative;
}

.autocomplete-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 2px);
  z-index: 900;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-md);
}

.autocomplete-results:empty {
  display: none;
}

.autocomplete-option {
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid #eef2f7;
  background: #fff;
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.autocomplete-option:hover,
.autocomplete-option:focus,
.autocomplete-option.active {
  background: #eff6ff;
  outline: none;
}

.autocomplete-option strong {
  font-size: 14px;
  line-height: 1.3;
}

.autocomplete-option small,
.autocomplete-empty,
.muted-text {
  color: var(--color-muted);
  font-size: 12px;
}

.autocomplete-empty {
  padding: 11px 12px;
}

.selected-list,
.responsables-inline-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.selected-list.compact {
  margin-top: 8px;
}

.selected-pill,
.responsable-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 13px;
  font-weight: 650;
}

.selected-pill span,
.responsable-pill {
  overflow-wrap: anywhere;
}

.selected-pill button {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: #dbeafe;
  color: #1d4ed8;
  cursor: pointer;
  line-height: 1;
  flex: 0 0 auto;
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.badge-ingresado {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-proceso {
  background: #fef9c3;
  color: #a16207;
}

.badge-en_proceso,
.badge-pendiente {
  background: #fef9c3;
  color: #a16207;
}

.badge-finalizado {
  background: #dcfce7;
  color: #166534;
}

.badge-completado,
.badge-activo {
  background: #dcfce7;
  color: #166534;
}

.badge-rechazado {
  background: #fee2e2;
  color: #991b1b;
}

.badge-inactivo {
  background: #f1f5f9;
  color: #475569;
}

/* ===== LOGIN ===== */
.login-container {
  position: relative;
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(30, 41, 59, 0.72)),
    linear-gradient(115deg, #0f172a 0%, #1e3a8a 48%, #0f766e 100%);
}

.login-container::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(135deg, rgba(0, 0, 0, 0.82), transparent 72%);
  pointer-events: none;
}

.login-container::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 42%;
  background: linear-gradient(180deg, transparent, rgba(15, 23, 42, 0.42));
  pointer-events: none;
}

.login-box {
  position: relative;
  z-index: 2;
  width: 350px;
  padding: 40px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  backdrop-filter: blur(10px);
}

.login-box h2 {
  margin-bottom: 25px;
  color: #1e293b;
  font-weight: 600;
}

.login-box p {
  margin-bottom: 20px;
  color: #64748b;
  font-size: 13px;
}

.login-box input {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-box input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.login-box button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.login-box button:hover {
  background: #1d4ed8;
}

.login-page {
  padding: clamp(18px, 4vw, 48px);
  background:
    radial-gradient(circle at 12% 18%, rgba(56, 189, 248, 0.22), transparent 30%),
    radial-gradient(circle at 86% 12%, rgba(37, 99, 235, 0.16), transparent 28%),
    linear-gradient(135deg, #eef4ff 0%, #f8fafc 42%, #eefdf9 100%);
}

.login-page::before,
.login-page::after {
  display: none;
}

.login-shell {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1fr);
  width: min(1120px, 100%);
  min-height: min(720px, calc(100vh - 56px));
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.16);
}

.login-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100%;
  padding: clamp(28px, 4vw, 54px);
  overflow: hidden;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    radial-gradient(circle at 24% 16%, rgba(56, 189, 248, 0.48), transparent 25%),
    radial-gradient(circle at 78% 72%, rgba(20, 184, 166, 0.38), transparent 30%),
    linear-gradient(145deg, #0f172a 0%, #1e3a8a 54%, #0f766e 100%);
  background-size: 54px 54px, 54px 54px, auto, auto, auto;
}

.login-visual::before {
  content: "";
  position: absolute;
  inset: 13% -22% auto auto;
  width: 360px;
  height: 360px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.login-visual::after {
  content: "";
  position: absolute;
  inset: auto auto -90px -90px;
  width: 260px;
  height: 260px;
  border: 38px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}

.login-visual-top,
.login-visual-content,
.login-visual-footer {
  position: relative;
  z-index: 1;
}

.login-visual-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand-mark,
.login-mobile-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.2);
}

.login-brand-mark {
  width: 52px;
  height: 52px;
}

.login-brand-mark img,
.login-mobile-mark img {
  display: block;
  width: 34px;
  height: 34px;
}

.login-brand-name {
  font-size: 25px;
  font-weight: 800;
}

.login-kicker {
  display: inline-flex;
  margin-bottom: 18px;
  color: #bfdbfe;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.login-visual h1 {
  max-width: 420px;
  margin: 0;
  font-size: 48px;
  line-height: 1.02;
  letter-spacing: 0;
}

.login-visual p {
  max-width: 390px;
  margin-top: 20px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 15px;
  line-height: 1.7;
}

.login-visual-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.login-visual-footer span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  font-weight: 700;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: clamp(34px, 6vw, 72px);
  background: #fff;
}

.login-panel-header {
  margin-bottom: 28px;
}

.login-mobile-mark {
  display: none;
  width: 46px;
  height: 46px;
  margin-bottom: 22px;
  background: #eff6ff;
  box-shadow: none;
}

.login-eyebrow {
  display: block;
  margin-bottom: 8px;
  color: #2563eb;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-panel h2 {
  margin: 0;
  color: #111827;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: 0;
}

.login-panel p {
  margin-top: 10px;
  color: #64748b;
  font-size: 14px;
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-field {
  position: relative;
  display: grid;
  gap: 8px;
  color: #334155;
  font-size: 13px;
  font-weight: 750;
}

.login-field i {
  position: absolute;
  left: 16px;
  bottom: 16px;
  color: #94a3b8;
  font-size: 16px;
  pointer-events: none;
}

.login-field input {
  width: 100%;
  min-height: 52px;
  padding: 14px 16px 14px 46px;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  background: #f8fafc;
  color: #111827;
  font-size: 14px;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.login-field input:focus {
  outline: none;
  border-color: #2563eb;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.13);
}

.login-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  margin-top: 4px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 16px 30px rgba(37, 99, 235, 0.24);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.login-submit:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  box-shadow: 0 18px 34px rgba(37, 99, 235, 0.3);
  transform: translateY(-1px);
}

.login-submit:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 3px;
}

.login-footer {
  margin-top: 18px;
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
}

.login-credit {
  display: block;
  margin-top: 10px;
  color: #94a3b8;
  font-size: 10px;
  line-height: 1.6;
  font-weight: 600;
}

.login-credit a {
  display: block;
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.2s ease;
}

.login-credit a:hover {
  color: var(--color-primary);
}

@media (max-width: 920px) {
  .login-page {
    align-items: flex-start;
    overflow-y: auto;
    padding: 24px;
  }

  .login-shell {
    grid-template-columns: 1fr;
    min-height: auto;
    max-width: 560px;
  }

  .login-visual {
    min-height: 220px;
    padding: 28px;
  }

  .login-visual-content {
    margin-top: 48px;
  }

  .login-visual h1 {
    max-width: 360px;
    font-size: 34px;
  }

  .login-visual p {
    margin-top: 12px;
  }

  .login-panel {
    max-width: none;
    padding: 36px;
  }
}

@media (max-width: 620px) {
  .login-page {
    padding: 18px;
  }

  .login-shell {
    border-radius: 18px;
  }

  .login-visual {
    display: none;
  }

  .login-panel {
    padding: 30px 22px;
  }

  .login-mobile-mark {
    display: inline-flex;
  }

  .login-panel h2 {
    font-size: 28px;
  }

  .login-field input,
  .login-submit {
    min-height: 50px;
  }
}
/* ===== FILE UPLOAD ===== */
.upload-box {
  border: 2px dashed #cbd5e1;
  padding: 30px;
  text-align: center;
  border-radius: 12px;
  background: #f8fafc;
  transition: background 0.3s, border-color 0.3s;
  cursor: pointer;
}

.upload-box:hover {
  border-color: #2563eb;
  background: #eff6ff;
}
.file-preview-list {
  margin-top: 15px;
}

.file-preview-list h5 {
  margin-bottom: 10px;
  color: #334155;
}

.file-preview-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 8px;
}
.despacho-info-table th {
  width: 180px;
  background: #f8fafc;
  font-weight: 600;
}

.despacho-info-table td {
  width: 25%;
}
.filters-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 16px;
  align-items: end;
}

.filters-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

.results-actions {
  align-items: center;
  margin-bottom: 16px;
}

.results-summary {
  margin-right: auto;
}

.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.results-navigation {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
}

.results-navigation .results-summary {
  margin-right: 0;
}

.results-per-page-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.results-per-page-form select {
  height: 38px;
  min-width: 72px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 0 30px 0 10px;
  font-size: 14px;
  font-weight: 700;
}

.results-per-page-submit {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #f8fafc;
  color: var(--color-text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.results-export-actions {
  margin-top: 0;
}

.compact-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  max-width: 100%;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.compact-pagination-top {
  justify-content: flex-start;
}

.compact-pagination-link,
.compact-pagination-ellipsis {
  flex: 0 0 auto;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.compact-pagination-link:first-child {
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
}

.compact-pagination-link:last-child {
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.compact-pagination-link:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--color-primary-dark);
}

.compact-pagination-link.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.16);
}

.compact-pagination-control {
  font-size: 16px;
}

.compact-pagination-ellipsis {
  color: var(--color-muted);
  background: #f8fafc;
}

@media (max-width: 1100px) {
  .filters-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1400px) and (min-width: 1101px) {
  .filters-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 650px) {
  .filters-grid {
    grid-template-columns: 1fr;
  }
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 20px;
}

.dash-card {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border-radius: 18px;
  color: white;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
}

.dash-card::after {
  content: "";
  position: absolute;
  right: -28px;
  bottom: -38px;
  width: 118px;
  height: 118px;
  border: 22px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
}

.dash-card span {
  position: relative;
  z-index: 1;
  display: block;
  font-size: 13px;
  opacity: 0.9;
  margin-bottom: 8px;
}

.dash-card strong {
  position: relative;
  z-index: 1;
  font-size: 30px;
}

.dash-card small {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 650;
}

.dash-blue {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
}

.dash-cyan {
  background: linear-gradient(135deg, #0369a1, #38bdf8);
}

.dash-yellow {
  background: linear-gradient(135deg, #a16207, #facc15);
}

.dash-green {
  background: linear-gradient(135deg, #166534, #22c55e);
}

.dash-red {
  background: linear-gradient(135deg, #991b1b, #ef4444);
}

.dashboard-two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.dashboard-panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  align-items: start;
}

.dashboard-panel-grid .card {
  min-width: 0;
}

.dashboard-panel-grid .table {
  table-layout: fixed;
}

.dashboard-panel-grid .table th,
.dashboard-panel-grid .table td {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

.dashboard-panel-grid .table .btn {
  width: 100%;
  min-width: 0;
  padding-left: 10px;
  padding-right: 10px;
}

.dashboard-insights {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
  gap: 18px;
  margin-bottom: 18px;
}

.dashboard-chart-card {
  min-height: 310px;
}

.dashboard-card-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.dashboard-card-title span {
  color: var(--color-muted);
  font-size: 13px;
  font-weight: 700;
}

.status-donut-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  align-items: center;
  gap: 24px;
}

.status-donut {
  width: 180px;
  aspect-ratio: 1;
  padding: 18px;
  border-radius: 50%;
  background: var(--donut);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06), 0 18px 40px rgba(15, 23, 42, 0.12);
}

.status-donut > div {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.status-donut strong {
  color: var(--color-text);
  font-size: 34px;
  line-height: 1;
}

.status-donut span {
  margin-top: 5px;
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-list {
  min-width: 0;
}

.status-row {
  margin-bottom: 16px;
}

.status-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 14px;
}

.status-label span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.status-label i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 10px;
}

.status-bar {
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.status-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
  border-radius: 999px;
}

.trend-chart {
  min-height: 230px;
  display: grid;
  grid-template-columns: repeat(6, minmax(44px, 1fr));
  gap: 14px;
  align-items: end;
}

.trend-item {
  min-width: 0;
  display: grid;
  grid-template-rows: 24px 170px 28px;
  gap: 8px;
  align-items: end;
  text-align: center;
}

.trend-value {
  color: var(--color-text);
  font-size: 13px;
  font-weight: 800;
}

.trend-track {
  position: relative;
  height: 170px;
  border-radius: 14px;
  background: linear-gradient(180deg, #f8fafc, #eef2ff);
  overflow: hidden;
}

.trend-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 8px;
  border-radius: 14px 14px 0 0;
  background: linear-gradient(180deg, #38bdf8, #2563eb);
  box-shadow: 0 -8px 20px rgba(37, 99, 235, 0.2);
}

.trend-item small {
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 750;
}

@media (max-width: 1200px) {
  .dashboard-insights,
  .dashboard-two-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 650px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .status-donut-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .status-list {
    width: 100%;
  }

  .trend-chart {
    grid-template-columns: repeat(3, minmax(64px, 1fr));
    row-gap: 18px;
  }

  .trend-item {
    grid-template-rows: 22px 120px 26px;
  }

  .trend-track {
    height: 120px;
  }
}

@media (max-width: 768px) {
  html,
  body {
    min-height: 100%;
  }

  .wrapper {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .mobile-menu-toggle {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1200;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--color-sidebar);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    box-shadow: var(--shadow-md);
    cursor: pointer;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1300;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 20px 0 40px rgba(15, 23, 42, 0.25);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
  }

  .sidebar-brand {
    padding-right: 42px;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 1250;
    display: block;
    background: rgba(15, 23, 42, 0.52);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .main {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    padding: 72px 14px 18px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
  }

  .topbar-user {
    width: 100%;
    justify-content: flex-end;
  }

  .filters-actions {
    flex-wrap: wrap;
  }

  .results-summary {
    flex: 1 0 100%;
    margin-right: 0;
  }

  .results-toolbar,
  .results-navigation,
  .results-export-actions {
    width: 100%;
  }

  .results-toolbar {
    align-items: stretch;
  }

  .results-navigation {
    align-items: flex-start;
  }

  .results-per-page-form {
    flex: 0 0 auto;
  }

  .results-export-actions {
    margin-top: 0;
  }

  .results-export-actions .btn {
    flex: 1 1 140px;
    justify-content: center;
  }

  .compact-pagination {
    justify-content: flex-start;
  }

  .despacho-form {
    max-width: none;
  }

  .autocomplete-results {
    position: static;
    margin-top: 6px;
    max-height: 220px;
  }

  .table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
  }

  .despacho-info-table {
    display: table;
    white-space: normal;
  }

  .despacho-info-table th,
  .despacho-info-table td {
    overflow-wrap: anywhere;
  }

  .historial-table-wrap {
    overflow-x: visible;
    border: 0;
    border-radius: 0;
  }

  .historial-event-table {
    display: table;
    min-width: 0;
    table-layout: auto;
    white-space: normal;
    border-collapse: separate;
    border-spacing: 0 12px;
  }

  .historial-event-table thead {
    display: none;
  }

  .historial-event-table tbody,
  .historial-event-table tr,
  .historial-event-table td {
    display: block;
    width: 100%;
  }

  .historial-event-table tr {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }

  .historial-event-table tr:hover {
    background: #fff;
  }

  .historial-event-table td {
    padding: 10px 12px 10px 120px;
    min-height: 40px;
    border-bottom: 1px solid #eef2f7;
    position: relative;
  }

  .historial-event-table td:last-child {
    border-bottom: 0;
  }

  .historial-event-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 12px;
    top: 10px;
    width: 92px;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
  }
}

@media (max-width: 480px) {
  .login-container {
    align-items: flex-start;
    padding: 48px 16px 24px;
  }

  .login-page {
    padding: 18px;
  }

  .login-box {
    width: 100%;
    max-width: 350px;
    padding: 32px 24px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-user {
    justify-content: space-between;
  }

  .notification-menu {
    position: static;
  }

  .notification-dropdown {
    left: 12px;
    right: 12px;
    width: auto;
    max-height: calc(100vh - 128px);
  }

  .notification-page-item {
    flex-direction: column;
    align-items: stretch;
  }

  .notification-page-item .btn {
    width: 100%;
    text-align: center;
  }

  .notification-pagination {
    padding-left: 12px;
    padding-right: 12px;
  }

  .user-menu-toggle {
    max-width: calc(100vw - 96px);
  }

  .user-meta {
    min-width: 0;
  }

  .user-meta strong {
    max-width: 130px;
  }

  .topbar .btn,
  .filters-actions .btn,
  .filters-actions button {
    width: 100%;
    text-align: center;
  }

  .filters-actions {
    justify-content: stretch;
  }

  .selected-list,
  .responsables-inline-list {
    flex-direction: column;
    align-items: stretch;
  }

  .selected-pill,
  .responsable-pill,
  .file-preview-item {
    width: 100%;
  }

  .file-preview-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .despacho-info-table,
  .despacho-info-table tbody,
  .despacho-info-table tr,
  .despacho-info-table th,
  .despacho-info-table td {
    display: block;
    width: 100%;
  }

  .despacho-info-table th {
    padding-bottom: 4px;
    border-bottom: 0;
  }

  .despacho-info-table td {
    padding-top: 4px;
  }

  .historial-event-table td {
    padding: 32px 12px 10px;
  }

  .historial-event-table td::before {
    top: 9px;
    width: calc(100% - 24px);
  }
}

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.55);
}

.modal-backdrop.open {
  display: flex;
}

.modal-dialog {
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-md);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--color-border);
}

.modal-header h4 {
  margin: 0;
  color: var(--color-text);
  font-size: 17px;
}
.modal-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--radius-md);
  background: #f1f5f9;
  color: #475569;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.modal-form {
  padding: 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

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

.btn-autocomplete-create {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 12px;
  flex: 0 0 auto;
}

@media (max-width: 480px) {
  .modal-backdrop {
    align-items: flex-start;
    padding: 76px 14px 18px;
  }

  .modal-actions,
  .autocomplete-empty-action {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-actions .btn,
  .btn-autocomplete-create {
    width: 100%;
  }
}

.datetime-fallback-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(120px, 0.65fr);
  gap: 10px;
}

@media (max-width: 480px) {
  .datetime-fallback-grid {
    grid-template-columns: 1fr;
  }
}

.login-secondary-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 38px;
  margin-top: 12px;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  color: #2563eb;
  background: rgba(239, 246, 255, 0.72);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.login-secondary-action:hover {
  background: #dbeafe;
  border-color: #bfdbfe;
  color: #1d4ed8;
  text-decoration: none;
}
/* ===== AYUDA / MANUAL ===== */
.help-card {
  max-width: 1180px;
  margin: 0 auto;
}

.help-document {
  color: #1f2937;
  font-size: 14px;
  line-height: 1.7;
}

.help-document h2,
.help-document h3,
.help-document h4,
.help-document h5,
.help-document h6 {
  color: #0f172a;
  line-height: 1.25;
  letter-spacing: 0;
}

.help-document h2 {
  margin: 0 0 18px;
  font-size: 28px;
}

.help-document h3 {
  margin: 34px 0 14px;
  padding-top: 22px;
  border-top: 1px solid #e5e7eb;
  font-size: 22px;
}

.help-document h4 {
  margin: 24px 0 10px;
  font-size: 18px;
}

.help-document h5,
.help-document h6 {
  margin: 18px 0 8px;
  font-size: 15px;
}

.help-document p {
  margin: 0 0 14px;
  color: #334155;
}

.help-document ul,
.help-document ol {
  margin: 0 0 18px 22px;
  color: #334155;
}

.help-document li {
  margin-bottom: 7px;
}

.help-document code {
  padding: 2px 5px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #1e3a8a;
  font-size: 13px;
}

.help-table {
  margin: 12px 0 22px;
}

.help-table th,
.help-table td {
  vertical-align: top;
  white-space: normal;
}

.help-figure {
  margin: 18px 0 28px;
}

.help-figure img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.help-figure figcaption {
  margin-top: 8px;
  color: #64748b;
  font-size: 12px;
  text-align: center;
}

@media (max-width: 768px) {
  .help-card {
    padding: 18px;
  }

  .help-document h2 {
    font-size: 24px;
  }

  .help-document h3 {
    font-size: 20px;
  }
}
/* ===== DESPACHOS MOBILE ===== */
.despacho-row-actions {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
}

.despacho-row-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

@media (max-width: 768px) {
  .despacho-row-actions {
    gap: 6px;
    min-width: max-content;
  }

  .despacho-row-actions .btn {
    min-width: 40px;
    min-height: 40px;
    padding: 9px 10px;
    border-radius: 12px;
    line-height: 1;
    white-space: nowrap;
  }

  .despacho-row-actions .btn:not(:first-child) {
    width: 40px;
    padding-right: 0;
    padding-left: 0;
    font-size: 0;
  }

  .despacho-row-actions .btn:not(:first-child) span,
  .despacho-row-actions .btn:not(:first-child) i {
    font-size: 16px;
    line-height: 1;
  }
}
