/* ===== 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-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 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.notification-pagination span {
  color: var(--color-muted);
  font-size: 14px;
  font-weight: 700;
}

.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;
}

/* ===== 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 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 {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
}

.login-box {
  background: #fff;
  padding: 40px;
  border-radius: 14px;
  width: 320px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.login-box h2 {
  margin-bottom: 20px;
  text-align: center;
}

/* ===== FILE UPLOAD ===== */
.upload-box {
  border: 2px dashed #ccc;
  padding: 20px;
  text-align: center;
  border-radius: 10px;
  cursor: pointer;
}

.upload-box:hover {
  border-color: #2563eb;
}
/* ===== LOGIN MODERNO ===== */

/* ===== LOGIN MODERNO PRO ===== */

.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;

  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);

  padding: 40px;
  border-radius: 16px;
  width: 350px;

  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}

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

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

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

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

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

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

/* Footer */
.login-footer {
  margin-top: 15px;
  font-size: 12px;
  color: #94a3b8;
}
.upload-box {
  border: 2px dashed #cbd5e1;
  padding: 30px;
  text-align: center;
  border-radius: 12px;
  background: #f8fafc;
  transition: 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(5, minmax(160px, 1fr));
  gap: 16px;
  align-items: end;
}

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

@media (max-width: 1100px) {
  .filters-grid {
    grid-template-columns: repeat(2, 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-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;
  }

  .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-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 {
    flex-direction: column;
    align-items: stretch;
  }

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

  .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);
  }
}
