.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-raised);
  border: 1px solid rgba(217, 226, 236, 0.86);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.stat::after {
  content: "";
  position: absolute;
  inset: auto -28px -42px auto;
  width: 105px;
  height: 105px;
  border-radius: 999px;
  background: rgba(12, 43, 94, 0.06);
}

.stat:hover {
  transform: translateY(-3px);
  border-color: rgba(135, 167, 216, 0.62);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--brand-primary);
  background: linear-gradient(145deg, rgba(12, 43, 94, 0.1), rgba(201, 168, 76, 0.16));
}

.stat-icon svg {
  width: 23px;
  height: 23px;
}

.stat-content {
  min-width: 0;
  position: relative;
  z-index: 1;
}

.stat-label {
  margin-bottom: 3px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.stat-val {
  color: var(--brand-primary);
  font-size: 25px;
  line-height: 1.1;
  font-weight: 850;
}

.btn,
.icon-btn {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 750;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.btn {
  min-height: 36px;
  padding: 8px 14px;
  font-size: 13px;
}

.btn-sm {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
}

.btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.btn:focus-visible,
.icon-btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn-primary,
.btn-gold,
.btn-green,
.btn-teal,
.btn-red,
.btn-purple {
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.btn-primary { background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-hover)); }
.btn-primary:hover { background: linear-gradient(135deg, #08214b, var(--brand-primary-hover)); }
.btn-gold { background: linear-gradient(135deg, var(--brand-gold), var(--brand-gold-hover)); }
.btn-gold:hover { background: var(--brand-gold-hover); }
.btn-green { background: linear-gradient(135deg, var(--brand-green), var(--brand-green-hover)); }
.btn-green:hover { background: var(--brand-green-hover); }
.btn-teal { background: linear-gradient(135deg, var(--brand-teal), var(--brand-teal-hover)); }
.btn-teal:hover { background: var(--brand-teal-hover); }
.btn-red { background: linear-gradient(135deg, var(--brand-red), var(--brand-red-hover)); }
.btn-red:hover { background: var(--brand-red-hover); }
.btn-purple { background: linear-gradient(135deg, var(--brand-purple), var(--brand-purple-hover)); }
.btn-purple:hover { background: var(--brand-purple-hover); }

.table-wrap {
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(217, 226, 236, 0.92);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 14px;
  background: #f3f7fb;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid #edf2f7;
  color: var(--text-primary);
  vertical-align: middle;
}

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

tbody tr {
  transition: background 0.16s ease, transform 0.16s ease;
}

tbody tr:hover td {
  background: #f8fbff;
}

.badge,
.status-pill,
.svc-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1;
  font-weight: 800;
  white-space: nowrap;
}

.svc-pill {
  background: #edf5ff;
  color: var(--brand-primary);
  border: 1px solid #d7e7fb;
}

.s-Nuevo { background: var(--status-nuevo-bg); color: var(--status-nuevo-text); }
.s-Cotizado { background: var(--status-cotizado-bg); color: var(--status-cotizado-text); }
.s-proceso { background: var(--status-proceso-bg); color: var(--status-proceso-text); }
.s-pendiente { background: var(--status-pendiente-bg); color: var(--status-pendiente-text); }
.s-Completado { background: var(--status-completado-bg); color: var(--status-completado-text); }
.s-perdido { background: var(--status-perdido-bg); color: var(--status-perdido-text); }
.f-Pendiente { background: var(--status-cotizado-bg); color: var(--status-cotizado-text); }
.f-Pagada { background: var(--status-completado-bg); color: var(--status-completado-text); }
.f-Cancelada { background: var(--status-perdido-bg); color: var(--status-perdido-text); }
.t-pendiente { background: var(--status-pendiente-bg); color: var(--status-pendiente-text); }
.t-proceso { background: var(--status-proceso-bg); color: var(--status-proceso-text); }
.t-hecho { background: var(--status-completado-bg); color: var(--status-completado-text); }

.avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--brand-primary), var(--brand-sky));
  color: #fff;
  font-size: 11px;
  font-weight: 850;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.avatar-lg {
  width: 52px;
  height: 52px;
  font-size: 15px;
}

.client-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
}

.icon-btn {
  min-height: 32px;
  min-width: 34px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

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

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

.topbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.topbar input,
.topbar select {
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.topbar input:focus,
.topbar select:focus {
  border-color: var(--brand-primary);
  box-shadow: var(--focus-ring);
}

.topbar input {
  flex: 1;
  min-width: 220px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1200;
  display: block;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--brand-green);
  color: #fff;
  font-weight: 750;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

#alerts-container {
  position: fixed;
  top: 94px;
  right: 20px;
  width: min(360px, calc(100vw - 32px));
  max-height: 440px;
  overflow-y: auto;
  z-index: 500;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 9px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  animation: alertIn 0.24s ease both;
}

@keyframes alertIn {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: translateX(0); }
}

.alert-urgent { border-left-color: var(--brand-red); }
.alert-high { border-left-color: var(--brand-gold); }
.alert-medium { border-left-color: var(--brand-primary); }
.alert-icon { font-size: 18px; }
.alert-content { flex: 1; min-width: 0; }
.alert-title { margin-bottom: 2px; font-size: 13px; font-weight: 850; }
.alert-message { color: var(--text-secondary); font-size: 12px; line-height: 1.4; }
.alert-close { color: var(--text-muted); font-size: 18px; line-height: 1; padding: 0 3px; }
.alert-close:hover { color: var(--brand-red); }
