html {
  font-size: 16px;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 17px;
  }
}

:root {
  --fondo: #0b1117;
  --panel: #131a22;
  --panel-2: #19222c;
  --panel-3: #22303c;
  --borde: #3b4b5e;
  --borde-fuerte: #4f647a;
  --texto: #f8fafc;
  --texto-suave: #cbd5e1;

  --azul: #3b82f6;
  --azul-hover: #2563eb;
  --celeste: #06b6d4;
  --verde: #22c55e;
  --verde-suave: #86efac;
  --amarillo: #f59e0b;
  --rojo: #ef4444;
  --negro-premium: #05070a;
  --dorado: #facc15;

  --sombra: 0 14px 30px rgba(0, 0, 0, 0.38);
  --sombra-hover: 0 20px 45px rgba(0, 0, 0, 0.52);
  --transicion: all 0.25s ease;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.11), transparent 24%),
    radial-gradient(circle at top right, rgba(34, 197, 94, 0.08), transparent 20%),
    linear-gradient(180deg, #0b1117 0%, #0f1419 100%);
  color: var(--texto);
  font-size: 1rem;
}

/* Layout */
.container {
  width: min(calc(100% - 24px), 1800px) !important;
  max-width: 1800px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.container-fluid {
  width: min(calc(100% - 24px), 1800px) !important;
  max-width: 1800px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

main,
.app-main {
  padding-top: 1.6rem;
  padding-bottom: 3rem;
}

.app-main > .container,
.app-main > .container-fluid {
  width: min(calc(100% - 24px), 1800px) !important;
  max-width: 1800px !important;
}

@media (max-width: 768px) {
  .container,
  .container-fluid,
  .app-main > .container,
  .app-main > .container-fluid {
    width: calc(100% - 16px) !important;
    max-width: calc(100% - 16px) !important;
  }
}

/* Textos */
h1 {
  font-size: 2.15rem;
  font-weight: 900;
  color: var(--texto);
  margin-bottom: 0.25rem;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 1.85rem;
  font-weight: 900;
  color: var(--texto);
}

h3,
h4,
h5,
h6 {
  color: var(--texto);
  font-weight: 800;
}

p {
  color: var(--texto-suave);
  font-size: 1rem;
}

.text-muted {
  color: var(--texto-suave) !important;
}

/* Navbar */
.navbar {
  background: rgba(19, 26, 34, 0.94) !important;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--borde-fuerte) !important;
  box-shadow: 0 5px 22px rgba(0, 0, 0, 0.28);
}

.navbar-brand {
  color: var(--texto) !important;
  font-size: 1.2rem;
  font-weight: 900;
}

.navbar .nav-link,
.navbar .nav-link.text-dark {
  color: var(--texto-suave) !important;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 0.55rem 0.85rem !important;
  transition: var(--transicion);
}

.navbar .nav-link:hover {
  color: #ffffff !important;
  background: rgba(59, 130, 246, 0.14);
  transform: translateY(-1px);
}

.navbar-toggler {
  border-color: var(--borde-fuerte);
}

/* Cards generales */
.card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(30, 41, 53, 0.98) 0%, rgba(20, 29, 39, 0.98) 100%);
  color: var(--texto);
  border: 1px solid var(--borde-fuerte);
  border-radius: 18px;
  box-shadow:
    var(--sombra),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: var(--transicion);
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 18px;
  padding: 1px;
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.45),
    rgba(34, 197, 94, 0.22),
    rgba(255, 255, 255, 0.03)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(34, 197, 94, 0.45);
  box-shadow:
    var(--sombra-hover),
    0 0 0 1px rgba(34, 197, 94, 0.18),
    0 0 28px rgba(34, 197, 94, 0.08);
}

.card-body {
  position: relative;
  z-index: 1;
  padding: 1.35rem;
}

.shadow-sm {
  box-shadow: var(--sombra) !important;
}

/* Dashboard premium */
.dashboard-card {
  min-height: 165px;
}

.dashboard-card .card-body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-label {
  color: var(--texto-suave);
  text-transform: uppercase;
  letter-spacing: 0.055em;
  font-size: 0.82rem;
  font-weight: 800;
  margin-bottom: 0.45rem;
}

.metric-number {
  color: var(--verde-suave);
  font-size: 2.2rem;
  font-weight: 950;
  line-height: 1.05;
  margin-bottom: 0.55rem;
  text-shadow: 0 0 18px rgba(34, 197, 94, 0.14);
}

.metric-number.money {
  color: #93c5fd;
  text-shadow: 0 0 18px rgba(59, 130, 246, 0.16);
}

.metric-number.profit {
  color: var(--verde-suave);
  text-shadow: 0 0 18px rgba(34, 197, 94, 0.18);
}

.metric-description {
  color: var(--texto-suave);
  margin-bottom: 0;
  font-size: 0.98rem;
}

.metric-top-line {
  position: absolute;
  left: 0;
  top: 0;
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg, var(--azul), var(--verde));
}

.quick-actions-card {
  border-color: rgba(59, 130, 246, 0.42);
}

.quick-actions-title {
  margin-bottom: 1rem;
}

/* Colores de rentabilidad */
.rentabilidad-mala {
  color: #fecaca !important;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.rentabilidad-media {
  color: #fde68a !important;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.rentabilidad-buena {
  color: #bbf7d0 !important;
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(34, 197, 94, 0.45);
}

.rentabilidad-excelente {
  color: #ffffff !important;
  background:
    radial-gradient(circle at top right, rgba(250, 204, 21, 0.18), transparent 32%),
    linear-gradient(180deg, #05070a 0%, #10151d 100%);
  border: 1px solid rgba(250, 204, 21, 0.65);
  box-shadow:
    0 0 0 1px rgba(250, 204, 21, 0.16),
    0 14px 30px rgba(0, 0, 0, 0.48);
}

.numero-malo {
  color: #fca5a5 !important;
  text-shadow: 0 0 18px rgba(239, 68, 68, 0.18);
}

.numero-medio {
  color: #fde68a !important;
  text-shadow: 0 0 18px rgba(245, 158, 11, 0.18);
}

.numero-bueno {
  color: #86efac !important;
  text-shadow: 0 0 18px rgba(34, 197, 94, 0.18);
}

.numero-excelente {
  color: #ffffff !important;
  text-shadow:
    0 0 18px rgba(250, 204, 21, 0.24),
    0 0 4px rgba(255, 255, 255, 0.25);
}

.badge-rentabilidad {
  display: inline-block;
  min-width: 92px;
  text-align: center;
  padding: 0.42rem 0.7rem;
  border-radius: 999px;
  font-weight: 950;
  letter-spacing: 0.01em;
}

/* Tabla general */
.table-responsive {
  width: 100%;
  border: 1px solid var(--borde-fuerte);
  border-radius: 16px;
  overflow-x: auto;
  background: linear-gradient(180deg, #19222c 0%, #172029 100%);
  box-shadow: var(--sombra);
}

.table {
  width: 100%;
  margin-bottom: 0;
  color: var(--texto) !important;
  background-color: transparent !important;

  --bs-table-color: var(--texto);
  --bs-table-bg: transparent;
  --bs-table-border-color: rgba(255, 255, 255, 0.06);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.025);
  --bs-table-striped-color: var(--texto);
  --bs-table-hover-bg: rgba(34, 197, 94, 0.10);
  --bs-table-hover-color: #ffffff;
}

.table thead th {
  background: linear-gradient(180deg, #111923 0%, #0f1720 100%) !important;
  color: #ffffff !important;
  border-bottom: 1px solid var(--borde-fuerte) !important;
  padding: 0.95rem 0.85rem;
  font-size: 1rem;
  font-weight: 900;
  white-space: nowrap;
}

.table tbody td {
  background-color: transparent !important;
  color: var(--texto) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
  padding: 0.9rem 0.85rem;
  vertical-align: middle;
  font-size: 0.98rem;
  transition: var(--transicion);
}

.table tbody tr:nth-child(odd) {
  background-color: rgba(255, 255, 255, 0.018) !important;
}

.table tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.035) !important;
}

.table tbody tr:hover {
  background-color: rgba(34, 197, 94, 0.10) !important;
}

/* Tablas específicas */
.proveedores-table {
  width: 100%;
  min-width: 1100px;
  table-layout: fixed;
}

.proveedores-table .col-nombre {
  width: 18%;
}

.proveedores-table .col-telefono {
  width: 12%;
}

.proveedores-table .col-whatsapp {
  width: 12%;
}

.proveedores-table .col-email {
  width: 23%;
}

.proveedores-table .col-localidad {
  width: 12%;
}

.proveedores-table .col-fecha {
  width: 12%;
}

.proveedores-table .col-acciones {
  width: 220px;
}

.productos-table {
  width: 100%;
  min-width: 1150px;
  table-layout: fixed;
}

.productos-table .col-producto {
  width: 18%;
}

.productos-table .col-categoria {
  width: 14%;
}

.productos-table .col-unidad {
  width: 11%;
}

.productos-table .col-stock {
  width: 11%;
}

.productos-table .col-descripcion {
  width: 24%;
}

.productos-table .col-acciones {
  width: 220px;
}

.trabajos-table {
  width: 100%;
  min-width: 1380px;
  table-layout: auto;
}

.precios-table {
  width: 100%;
  min-width: 1120px;
  table-layout: auto;
}

.contactos-table {
  width: 100%;
  min-width: 1250px;
  table-layout: auto;
}

.email-cell,
.descripcion-cell {
  word-break: break-word;
}

.descripcion-cell {
  color: var(--texto-suave) !important;
}

.acciones-tabla {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.badge-stock-ok {
  display: inline-block;
  min-width: 82px;
  text-align: center;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(34, 197, 94, 0.35);
  font-weight: 900;
}

.badge-stock-bajo {
  display: inline-block;
  min-width: 82px;
  text-align: center;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.38);
  font-weight: 900;
}

/* Formularios */
.form-label {
  color: var(--texto);
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 0.45rem;
}

.form-control,
.form-select {
  background-color: #0f1720;
  color: var(--texto);
  border: 1px solid var(--borde-fuerte);
  border-radius: 12px;
  padding: 0.72rem 0.9rem;
  font-size: 1rem;
  transition: var(--transicion);
}

.form-control:hover,
.form-select:hover {
  border-color: rgba(34, 197, 94, 0.55);
}

.form-control:focus,
.form-select:focus {
  background-color: #0f1720;
  color: var(--texto);
  border-color: var(--verde);
  box-shadow: 0 0 0 0.22rem rgba(34, 197, 94, 0.20);
  transform: translateY(-1px);
}

.form-control::placeholder {
  color: #8ba0b4;
}

textarea.form-control {
  resize: vertical;
}

/* Validaciones */
.text-danger,
.field-validation-error {
  color: #fca5a5 !important;
  font-size: 0.95rem;
  font-weight: 800;
}

.field-validation-error {
  display: block;
  margin-top: 0.35rem;
}

/* Botones */
.btn {
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 900;
  border: none;
  padding: 0.6rem 0.92rem;
  transition: var(--transicion);
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.22);
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

.btn-sm {
  padding: 0.45rem 0.72rem;
  font-size: 0.9rem;
}

.btn-primary {
  background: linear-gradient(180deg, var(--azul) 0%, var(--azul-hover) 100%) !important;
  color: #ffffff !important;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #4b8df8 0%, var(--azul) 100%) !important;
  box-shadow: 0 10px 24px rgba(59, 130, 246, 0.30);
}

.btn-secondary {
  background: linear-gradient(180deg, #53657a 0%, #405166 100%) !important;
  color: #ffffff !important;
}

.btn-secondary:hover {
  background: linear-gradient(180deg, #64748b 0%, #475569 100%) !important;
}

.btn-info {
  background: linear-gradient(180deg, var(--celeste) 0%, #0891b2 100%) !important;
  color: #ffffff !important;
}

.btn-info:hover {
  background: linear-gradient(180deg, #22d3ee 0%, var(--celeste) 100%) !important;
  box-shadow: 0 10px 24px rgba(6, 182, 212, 0.25);
}

.btn-warning {
  background: linear-gradient(180deg, var(--amarillo) 0%, #d97706 100%) !important;
  color: #111827 !important;
}

.btn-warning:hover {
  background: linear-gradient(180deg, #fbbf24 0%, var(--amarillo) 100%) !important;
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.25);
}

.btn-danger {
  background: linear-gradient(180deg, var(--rojo) 0%, #dc2626 100%) !important;
  color: #ffffff !important;
}

.btn-danger:hover {
  background: linear-gradient(180deg, #f87171 0%, var(--rojo) 100%) !important;
  box-shadow: 0 10px 24px rgba(239, 68, 68, 0.25);
}

/* Alertas */
.alert {
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
  border-width: 1px;
}

.alert-info {
  background-color: rgba(6, 182, 212, 0.12);
  color: #bae6fd;
  border-color: rgba(6, 182, 212, 0.35);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.16) !important;
  color: #fde68a !important;
  border: 1px solid rgba(245, 158, 11, 0.45) !important;
}

.alert-warning strong {
  color: #facc15 !important;
}

/* Links */
a {
  color: #93c5fd;
  text-decoration: none;
  transition: var(--transicion);
}

a:hover {
  color: #bfdbfe;
}

/* Footer */
.footer {
  background-color: rgba(19, 26, 34, 0.95);
  color: var(--texto-suave) !important;
  border-top: 1px solid var(--borde-fuerte) !important;
  padding: 1rem 0;
  margin-top: 3rem;
  line-height: normal;
  position: static;
  width: 100%;
  white-space: normal;
}

/* Details / Delete prolijo */
.card dl.row {
  display: grid;
  grid-template-columns: 260px 1fr;
  column-gap: 0;
  row-gap: 0;
  margin: 0;

  --bs-gutter-x: 0;
  --bs-gutter-y: 0;
}

.card dl.row > dt,
.card dl.row > dd {
  width: 100% !important;
  max-width: none !important;
  flex: none !important;
  margin: 0;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.card dl.row > dt {
  color: #ffffff !important;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.015);
}

.card dl.row > dd {
  color: var(--texto-suave) !important;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.01);
}

.card dl.row > dt:last-of-type,
.card dl.row > dd:last-of-type {
  border-bottom: none;
}

/* Botones debajo de Delete / Details */
form.mt-3 .btn,
.d-flex.mt-3 .btn {
  min-width: 120px;
}

/* Detalles */
hr {
  border-color: rgba(255, 255, 255, 0.10);
}

::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

::-webkit-scrollbar-track {
  background: #0f1720;
}

::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Responsive */
@media (max-width: 768px) {
  .card dl.row {
    grid-template-columns: 1fr;
  }

  .card dl.row > dt {
    padding-bottom: 0.25rem;
    border-bottom: none;
  }

  .card dl.row > dd {
    padding-top: 0.25rem;
  }
}
