:root {
  --bg-1: #050816;
  --bg-2: #0f172a;
  --bg-3: #111827;
  --card: rgba(15, 23, 42, 0.88);
  --card-strong: rgba(8, 15, 30, 0.92);
  --text: #f8fafc;
  --text-soft: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: rgba(148, 163, 184, 0.16);
}

html,
body {
  min-height: 100vh;
}

body {
  color: var(--text);
  background: radial-gradient(circle at top, #111c44 0%, var(--bg-1) 45%, #02030a 100%);
  margin: 0;
}

.login-page {
  overflow: hidden;
}

.stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    radial-gradient(2px 2px at 10% 20%, white, transparent),
    radial-gradient(1px 1px at 80% 30%, white, transparent),
    radial-gradient(1.5px 1.5px at 30% 80%, #93c5fd, transparent),
    radial-gradient(2px 2px at 60% 70%, white, transparent),
    radial-gradient(1px 1px at 90% 10%, white, transparent);
  background-repeat: repeat;
  background-size: 320px 320px;
  z-index: 0;
}

main,
.navbar,
.card {
  position: relative;
  z-index: 1;
}

.mercury-nav,
.dashboard-card,
.glass-card {
  background: rgba(10, 16, 35, 0.82);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

.dashboard-card,
.glass-card {
  border-radius: 22px;
}

.navbar-brand,
.navbar .nav-link,
.navbar .navbar-text,
.navbar .btn,
.card-title,
.fw-bold,
h1, h2, h3, h4, h5, h6,
label,
th,
td,
span,
p,
div {
  color: inherit;
}

body,
p,
td,
label,
input,
select,
textarea,
li,
span,
div {
  color: var(--text-soft);
}

h1, h2, h3, h4, h5, h6,
.card-title,
.fw-bold,
.metric-value {
  color: #ffffff;
}

.dashboard-subtitle,
.text-secondary,
.form-text,
small,
.small {
  color: var(--muted) !important;
}

.metric-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  word-break: break-word;
}

.role-text {
  font-size: 1.3rem;
}

.mini-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
  font-weight: 700;
}

.card-body {
  color: var(--text-soft);
}

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-soft);
  --bs-table-border-color: rgba(148, 163, 184, 0.12);
  margin-bottom: 0;
}

.mercury-table thead th {
  color: #ffffff;
  font-weight: 700;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}

.mercury-table tbody td,
.mercury-table tbody th {
  color: var(--text-soft);
  border-color: rgba(148, 163, 184, 0.08);
  vertical-align: middle;
}

.mercury-table.table-hover tbody tr:hover {
  background: rgba(56, 189, 248, 0.06);
}

.form-control,
.form-select,
textarea {
  background: rgba(15, 23, 42, 0.8);
  color: #ffffff;
  border-color: rgba(148, 163, 184, 0.25);
}

.form-control::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

.form-control:focus,
.form-select:focus,
textarea:focus {
  background: rgba(15, 23, 42, 0.95);
  color: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 0 0 0.2rem rgba(56, 189, 248, 0.15);
}

.form-select option {
  background: #0f172a;
  color: #ffffff;
}

.btn-primary {
  background: linear-gradient(90deg, #2563eb, #06b6d4);
  border: 0;
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.08);
  color: #fff;
}

.btn-outline-light:hover {
  color: #000;
}

.alert {
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
}

.alert-success {
  background: rgba(34, 197, 94, 0.15);
}

.alert-danger {
  background: rgba(239, 68, 68, 0.15);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.15);
}

.alert-info {
  background: rgba(56, 189, 248, 0.15);
}

a {
  color: #7dd3fc;
}

a:hover {
  color: #bae6fd;
}

canvas {
  max-width: 100%;
}

#clientsMap,
#ordersMap,
[id^="clientsMapUser"],
[id^="ordersMapUser"] {
  width: 100%;
  height: 500px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #0b1120;
}

/* Tabs */
.mercury-tabs {
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.mercury-tabs .nav-link {
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 12px 12px 0 0;
  margin-right: 8px;
  margin-bottom: 8px;
  background: transparent;
  font-weight: 600;
  transition: all 0.2s ease;
}

.mercury-tabs .nav-link:hover {
  color: #ffffff;
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.18);
}

.mercury-tabs .nav-link.active {
  color: #ffffff;
  background: rgba(15, 23, 42, 0.95);
  border-color: rgba(56, 189, 248, 0.22);
  box-shadow: inset 0 2px 0 rgba(56, 189, 248, 0.7);
}

/* Role badges */
.role-badge {
  display: inline-block;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}

.role-super {
  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.role-controlador {
  background: rgba(56, 189, 248, 0.18);
  color: #bae6fd;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.role-admin {
  background: rgba(129, 140, 248, 0.18);
  color: #c7d2fe;
  border: 1px solid rgba(129, 140, 248, 0.35);
}

.role-operador {
  background: rgba(34, 197, 94, 0.18);
  color: #bbf7d0;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

/* Leaflet */
.leaflet-control-layers {
  background: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.leaflet-control-layers label {
  color: #e2e8f0 !important;
}

.leaflet-control-layers-toggle {
  filter: brightness(1.1);
}

.leaflet-control-zoom a {
  background-color: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.leaflet-control-zoom a:hover {
  background-color: #1e293b;
  color: #38bdf8;
}

.leaflet-control-attribution {
  background: rgba(2, 6, 23, 0.65) !important;
  color: #cbd5e1 !important;
}

.leaflet-control-attribution a {
  color: #7dd3fc !important;
}

.leaflet-popup-content-wrapper {
  background: rgba(15, 23, 42, 0.96);
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.leaflet-popup-tip {
  background: rgba(15, 23, 42, 0.96);
}

.leaflet-popup-content {
  margin: 12px 14px;
  color: #e2e8f0;
}

.map-popup-content strong {
  color: #38bdf8;
  display: inline-block;
  margin-bottom: 4px;
}

.map-popup-content span {
  display: block;
  margin-bottom: 2px;
  color: #e2e8f0;
}

/* Responsive */
@media (max-width: 992px) {
  #clientsMap,
  #ordersMap,
  [id^="clientsMapUser"],
  [id^="ordersMapUser"] {
    height: 420px;
  }
}

@media (max-width: 768px) {
  .metric-value {
    font-size: 1.6rem;
  }

  .role-text {
    font-size: 1.05rem;
  }

  #clientsMap,
  #ordersMap,
  [id^="clientsMapUser"],
  [id^="ordersMapUser"] {
    height: 360px;
  }
}

.btn-outline-light {
  border-color: rgba(148, 163, 184, 0.28);
  color: #e2e8f0;
  background: transparent;
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(148, 163, 184, 0.45);
  color: #ffffff;
}

.btn-outline-danger {
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
  background: transparent;
}

.btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ffffff;
}

/* =========================
   MODAL TOTALMENTE OSCURO
========================= */
.modal-content {
  background: rgba(10, 16, 35, 0.96) !important;
  color: var(--text-soft) !important;
  border: 1px solid var(--border) !important;
  border-radius: 22px;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.modal-header,
.modal-footer {
  background: transparent !important;
  border-color: rgba(148, 163, 184, 0.12) !important;
}

.modal-title {
  color: #ffffff !important;
}

.modal-body {
  background: transparent !important;
  color: var(--text-soft) !important;
}

.modal-backdrop.show {
  opacity: 0.75;
}

/* =========================
   FORMULARIOS DENTRO DE MODAL
========================= */
.modal .form-control,
.modal .form-select,
.modal textarea {
  background: rgba(15, 23, 42, 0.92) !important;
  color: #ffffff !important;
  border: 1px solid rgba(148, 163, 184, 0.25) !important;
}

.modal .form-control:focus,
.modal .form-select:focus,
.modal textarea:focus {
  background: rgba(15, 23, 42, 0.98) !important;
  color: #ffffff !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 0.2rem rgba(56, 189, 248, 0.15) !important;
}

.modal .form-label,
.modal .form-text {
  color: var(--text-soft) !important;
}

/* =========================
   SELECT MULTIPLE Y OPCIONES
========================= */
select[multiple],
.form-select[multiple] {
  background: rgba(15, 23, 42, 0.95) !important;
  color: #ffffff !important;
  border: 1px solid rgba(148, 163, 184, 0.25) !important;
}

select[multiple] option,
.form-select option {
  background: #0f172a !important;
  color: #ffffff !important;
}

select[multiple] option:checked,
.form-select option:checked {
  background: linear-gradient(90deg, #2563eb, #06b6d4) !important;
  color: #ffffff !important;
}

select[multiple]:focus option:checked {
  background: #1d4ed8 !important;
  color: #ffffff !important;
}

/* Firefox */
select[multiple] option:hover {
  box-shadow: 0 0 10px 100px rgba(56, 189, 248, 0.15) inset !important;
}

/* =========================
   DISABLED
========================= */
.form-control:disabled,
.form-select:disabled,
textarea:disabled {
  background: rgba(30, 41, 59, 0.9) !important;
  color: #cbd5e1 !important;
  border-color: rgba(148, 163, 184, 0.18) !important;
  opacity: 1 !important;
}

/* =========================
   LISTAS DE BOOTSTRAP
========================= */
.list-group,
.list-group-item {
  background: rgba(15, 23, 42, 0.9) !important;
  color: var(--text-soft) !important;
  border-color: rgba(148, 163, 184, 0.12) !important;
}

.list-group-item.active {
  background: rgba(56, 189, 248, 0.2) !important;
  border-color: rgba(56, 189, 248, 0.35) !important;
  color: #ffffff !important;
}

/* =========================
   DROPDOWNS
========================= */
.dropdown-menu {
  background: rgba(15, 23, 42, 0.97) !important;
  border: 1px solid rgba(148, 163, 184, 0.16) !important;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.dropdown-item {
  color: #e2e8f0 !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: rgba(56, 189, 248, 0.12) !important;
  color: #ffffff !important;
}

/* =========================
   AUTOFILL DEL NAVEGADOR
========================= */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: #ffffff !important;
  box-shadow: 0 0 0px 1000px rgba(15, 23, 42, 0.95) inset !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* =========================
   VARIABLES DE BOOTSTRAP 5
========================= */
.modal {
  --bs-modal-bg: rgba(10, 16, 35, 0.96);
  --bs-modal-color: #e2e8f0;
  --bs-modal-border-color: rgba(148, 163, 184, 0.16);
  --bs-modal-header-border-color: rgba(148, 163, 184, 0.12);
  --bs-modal-footer-border-color: rgba(148, 163, 184, 0.12);
}