/* ============================================================
   ImportCel · sistema de compra e importación de celulares
   ============================================================ */

:root {
  --navy: #0b1f38;
  --navy-2: #12315a;
  --navy-3: #1f4e79;
  --navy-4: #2f6ba3;
  --gold: #d4af37;
  --gold-2: #f0cf6b;
  --gold-soft: #f7ecc4;

  --bg: #eef2f7;
  --bg-2: #e3eaf3;
  --card: #ffffff;
  --card-2: #f8fafd;
  --text: #101c2e;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;

  --ok: #047857;
  --ok-bg: #d1fae5;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --info: #1d4ed8;
  --info-bg: #dbeafe;
  --purple: #6d28d9;
  --purple-bg: #ede9fe;

  --shadow-sm: 0 1px 2px rgba(11, 31, 56, 0.06), 0 2px 6px rgba(11, 31, 56, 0.04);
  --shadow: 0 4px 14px rgba(11, 31, 56, 0.07), 0 12px 34px rgba(11, 31, 56, 0.06);
  --shadow-lg: 0 10px 24px rgba(11, 31, 56, 0.12), 0 26px 60px rgba(11, 31, 56, 0.10);
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

html[data-tema="oscuro"] {
  --bg: #0a1526;
  --bg-2: #0d1c31;
  --card: #12243d;
  --card-2: #16294a;
  --text: #e8eef7;
  --muted: #93a5bd;
  --line: #21395c;
  --line-2: #2c4a75;
  --ok-bg: #06371f;
  --warn-bg: #3a2a06;
  --bad-bg: #3d1414;
  --info-bg: #10254f;
  --purple-bg: #241a4a;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --info: #93c5fd;
  --purple: #c4b5fd;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Inter", sans-serif;
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(31, 78, 121, 0.10), transparent 62%),
    radial-gradient(900px 460px at 92% 0%, rgba(212, 175, 55, 0.10), transparent 58%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy-3); text-decoration: none; transition: color .16s var(--ease); }
a:hover { text-decoration: none; color: var(--navy-4); }
html[data-tema="oscuro"] a { color: #8ab8e8; }

::selection { background: var(--gold-soft); color: var(--navy); }

/* --------------------------------------------------------------- header */

.app-header {
  background: linear-gradient(120deg, var(--navy) 0%, var(--navy-2) 48%, var(--navy-3) 100%);
  color: #fff;
  padding: 0 20px;
  box-shadow: 0 4px 18px rgba(11, 31, 56, 0.26);
  position: sticky;
  top: 0;
  z-index: 60;
  border-bottom: 1px solid rgba(212, 175, 55, 0.28);
}

.app-header::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.7;
}

.header-inner {
  max-width: 1480px;
  min-height: 58px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: nowrap;
}

/* Todos los íconos del encabezado quedan acotados aunque el CSS cargue tarde. */
.app-header svg { flex: none; display: block; }

.brand { display: flex; align-items: center; gap: 10px; color: #fff; flex: none; }
.brand:hover { color: #fff; }

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  object-fit: contain;
  background: #fff;
  padding: 2px;
  flex: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(212, 175, 55, 0.35);
  transition: transform .3s var(--ease);
}
.brand:hover .brand-logo { transform: scale(1.05); }

.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  color: var(--navy);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: -0.5px;
  flex: none;
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.32);
  transition: transform .3s var(--ease);
}
.brand:hover .logo-mark { transform: rotate(-6deg) scale(1.06); }

.brand-txt { line-height: 1.1; }
.brand h1 { font-size: 16px; line-height: 1.1; font-weight: 800; letter-spacing: -0.3px; white-space: nowrap; }
.brand small {
  display: block;
  opacity: 0.62;
  font-size: 10.5px;
  font-weight: 400;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px auto 22px;
  text-align: center;
}
.login-hero img {
  width: min(220px, 62vw);
  height: auto;
  border-radius: 18px;
  background: #fff;
  padding: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.login-hero p {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: center;
  overflow-x: auto;
  padding: 8px 0;
  scrollbar-width: none;
  position: relative;
  z-index: 1;
}
.nav::-webkit-scrollbar { display: none; }

.nav a,
.nav-item {
  color: #c7d9ec;
  min-width: 72px;
  padding: 8px 10px 7px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  text-align: center;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  transition: background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease), box-shadow .18s var(--ease);
}
.nav-ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.10);
  transition: background .18s var(--ease), border-color .18s var(--ease);
}
.nav a svg,
.nav-item svg {
  width: 18px;
  height: 18px;
  opacity: 0.9;
}
.nav-label { line-height: 1.1; max-width: 78px; overflow: hidden; text-overflow: ellipsis; }
.nav a:hover,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.14);
}
.nav a:hover .nav-ico,
.nav-item:hover .nav-ico {
  background: rgba(212, 175, 55, 0.18);
  border-color: rgba(212, 175, 55, 0.35);
}
.nav a.active,
.nav-item.active {
  background: rgba(212, 175, 55, 0.16);
  color: #fff;
  border-color: rgba(212, 175, 55, 0.42);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}
.nav a.active .nav-ico,
.nav-item.active .nav-ico {
  background: linear-gradient(145deg, rgba(240, 207, 107, 0.95), rgba(212, 175, 55, 0.9));
  border-color: transparent;
  color: var(--navy);
}
.nav a.active svg,
.nav-item.active svg { opacity: 1; color: var(--navy); }
.nav-badge {
  position: absolute;
  top: 4px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}
.nav a,
.nav-item { position: relative; }
.header-inner { min-height: 74px; }
.brand small { display: none; }
@media (min-width: 1200px) {
  .brand small { display: block; }
}
.rol-select { width: 100%; }
.rol-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.rol-inline .rol-select,
.rol-inline .rol-select-sm {
  min-width: 220px;
  flex: 1;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  position: relative;
  z-index: 5;
}
.icon-btn.is-off {
  opacity: 0.45;
  background: rgba(255, 255, 255, 0.06);
}
.icon-btn.is-off:hover { opacity: 0.75; }

.search-box { position: relative; display: flex; align-items: center; }
.search-box input {
  width: 190px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 7px 30px 7px 32px;
  border-radius: 9px;
  font-size: 13px;
  transition: width .25s var(--ease), background .2s var(--ease);
}
.search-box input::placeholder { color: #9fb6cf; }
.search-box input:focus {
  outline: none;
  width: 250px;
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(212, 175, 55, 0.6);
}
.search-box svg {
  position: absolute;
  left: 9px;
  width: 16px;
  height: 16px;
  color: #9fb6cf;
  pointer-events: none;
}
.search-box kbd {
  position: absolute; right: 7px;
  font-size: 10px; font-family: inherit; color: #9fb6cf;
  border: 1px solid rgba(255,255,255,0.2); border-radius: 5px; padding: 0 5px;
  pointer-events: none;
  transition: opacity .16s var(--ease);
}
.search-box input:focus ~ kbd, .search-box input:not(:placeholder-shown) ~ kbd { opacity: 0; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #dbe7f3;
  cursor: pointer;
  flex: none;
  transition: background .18s var(--ease);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.2); }
.icon-btn svg { width: 18px; height: 18px; }

/* ------------------------------------------------------ selector de idioma */

.lang-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 9px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #dbe7f3;
  cursor: pointer;
  flex: none;
  font: inherit;
  transition: background .18s var(--ease);
}
.lang-btn:hover { background: rgba(255, 255, 255, 0.2); }
.lang-flag { font-size: 16px; line-height: 1; }
.lang-sigla { font-size: 12px; font-weight: 800; letter-spacing: .06em; }
.lang-btn svg { width: 12px; height: 12px; opacity: .7; }

.modal-fondo {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 17, 32, 0.62);
  backdrop-filter: blur(3px);
}
.modal-fondo.visible { display: flex; animation: aparecer .18s var(--ease) both; }
body.modal-abierto { overflow: hidden; }

.modal-caja {
  position: relative;
  width: min(460px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 26px 24px 24px;
  animation: subir .25s var(--ease) both;
}
.modal-caja h3 { margin: 0 0 6px; font-size: 19px; color: var(--text); }
.modal-sub { margin: 0 0 18px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.modal-cerrar {
  position: absolute;
  top: 14px; right: 14px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--muted);
  cursor: pointer;
}
.modal-cerrar:hover { color: var(--text); border-color: var(--line-2); }

.lang-opciones { display: grid; gap: 10px; }
.lang-opcion {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: var(--card-2);
  text-decoration: none;
  color: var(--text);
  transition: border-color .18s var(--ease), transform .18s var(--ease), box-shadow .18s var(--ease);
}
.lang-opcion:hover { border-color: var(--navy-4); transform: translateY(-1px); box-shadow: var(--shadow); }
.lang-opcion.activa { border-color: var(--gold); background: var(--gold-soft); }
[data-tema="oscuro"] .lang-opcion.activa { background: rgba(212, 175, 55, 0.12); }
.lang-opcion-bandera { font-size: 27px; line-height: 1; }
.lang-opcion-txt { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.lang-opcion-txt strong { font-size: 15px; }
.lang-opcion-txt small { font-size: 12px; color: var(--muted); }
.lang-opcion-check { color: var(--gold); display: grid; place-items: center; }
[data-tema="oscuro"] .lang-opcion.activa .lang-opcion-txt small { color: var(--gold-soft); }

/* ---------------------------------------------------------------- layout */

.wrap { max-width: 1480px; margin: 0 auto; padding: 20px 20px 52px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  animation: subir .4s var(--ease) both;
}

.page-head h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.6px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.page-head h2 svg { flex: none; }
.page-head p { color: var(--muted); margin-top: 4px; font-size: 13.5px; max-width: 76ch; }
.page-head .actions { gap: 8px; }

@keyframes subir { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }

/* --------------------------------------------------------------- botones */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform .16s var(--ease), box-shadow .18s var(--ease), filter .18s var(--ease);
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,0.28), transparent 55%);
  opacity: 0; transition: opacity .25s var(--ease);
}
.btn:hover::after { opacity: 1; }

.btn-primary { background: linear-gradient(135deg, var(--navy-3), var(--navy-2)); color: #fff; box-shadow: 0 4px 14px rgba(31, 78, 121, 0.28); }
.btn-gold { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: var(--navy); box-shadow: 0 4px 14px rgba(212, 175, 55, 0.32); }
.btn-ghost { background: var(--card); color: var(--navy-3); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--navy-4); color: var(--navy-4); }
html[data-tema="oscuro"] .btn-ghost { color: #9dc3ea; }
.btn-danger { background: linear-gradient(135deg, #dc2626, #991b1b); color: #fff; }
.btn-excel { background: linear-gradient(135deg, #21a366, #107c41); color: #fff; box-shadow: 0 4px 14px rgba(16, 124, 65, 0.3); }
.btn-sm { padding: 7px 11px; font-size: 12px; border-radius: 9px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

/* ----------------------------------------------------------------- grids */

.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.two { grid-template-columns: 1.45fr 1fr; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* --------------------------------------------------------------- tarjetas */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  position: relative;
  animation: subir .45s var(--ease) both;
  transition: box-shadow .25s var(--ease), transform .25s var(--ease);
}
.card:hover { box-shadow: var(--shadow-lg); }

.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  animation: subir .45s var(--ease) both;
  transition: transform .22s var(--ease), box-shadow .22s var(--ease);
}
.kpi:nth-child(2) { animation-delay: .05s; }
.kpi:nth-child(3) { animation-delay: .1s; }
.kpi:nth-child(4) { animation-delay: .15s; }
.kpi:nth-child(5) { animation-delay: .2s; }
.kpi:nth-child(6) { animation-delay: .25s; }

.kpi::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--navy-4), var(--navy-3));
  opacity: 0.9;
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.kpi.kpi-gold::before { background: linear-gradient(180deg, var(--gold-2), var(--gold)); }
.kpi.kpi-ok::before { background: linear-gradient(180deg, #34d399, var(--ok)); }
.kpi.kpi-warn::before { background: linear-gradient(180deg, #fbbf24, var(--warn)); }
.kpi.kpi-bad::before { background: linear-gradient(180deg, #f87171, var(--bad)); }

.kpi .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi .value {
  font-size: 27px;
  font-weight: 800;
  margin: 7px 0 2px;
  letter-spacing: -0.9px;
  font-variant-numeric: tabular-nums;
}
.kpi .hint { color: var(--muted); font-size: 12px; }

.section-title {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--navy-3);
  margin: 2px 0 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}
html[data-tema="oscuro"] .section-title { color: #8ab8e8; }
.section-title::before {
  content: "";
  width: 3px; height: 14px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
}

/* ------------------------------------------------------------ formularios */

label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  background: var(--card);
  color: var(--text);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--navy-4); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy-3);
  box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.14);
}
input[readonly] { background: var(--bg-2); color: var(--muted); cursor: not-allowed; }
input[type="checkbox"] { width: auto; accent-color: var(--navy-3); width: 17px; height: 17px; cursor: pointer; }

textarea { min-height: 92px; resize: vertical; line-height: 1.55; }
.field { margin-bottom: 14px; }
.help { color: var(--muted); font-size: 11.5px; margin-top: 4px; line-height: 1.45; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

.check-inline {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background .16s var(--ease);
}
.check-inline:hover { background: var(--card-2); }

/* ---------------------------------------------------------------- tablas */

.table-wrap {
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  max-height: 74vh;
}
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--card-2);
  backdrop-filter: blur(8px);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 800;
  padding: 11px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
html[data-tema="oscuro"] th { background: #16294a; }

td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
tbody tr { transition: background .13s var(--ease); }
tbody tr:hover td { background: rgba(31, 78, 121, 0.045); }
html[data-tema="oscuro"] tbody tr:hover td { background: rgba(255, 255, 255, 0.04); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.oculto-filtro { display: none; }

/* --------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.st-analizando, .st-observando, .st-preparacion { background: var(--purple-bg); color: var(--purple); }
.st-lance_activo { background: #ffedd5; color: #9a3412; }
.st-ganado, .st-pagado { background: var(--ok-bg); color: var(--ok); }
.st-perdido { background: var(--bad-bg); color: var(--bad); }
.st-retirado, .st-en_leilao { background: var(--info-bg); color: var(--info); }
.st-comprado { background: var(--info-bg); color: var(--info); }
.st-enviado_usa, .st-en_transito { background: #cffafe; color: #0e7490; }
html[data-tema="oscuro"] .st-enviado_usa, html[data-tema="oscuro"] .st-en_transito { background: #0a3a44; color: #67e8f9; }
.st-en_aduana { background: var(--warn-bg); color: var(--warn); }
.st-recibido, .st-control_calidad { background: #ecfccb; color: #3f6212; }
html[data-tema="oscuro"] .st-recibido, html[data-tema="oscuro"] .st-control_calidad { background: #1f3308; color: #bef264; }
.st-listo_venta { background: var(--ok-bg); color: var(--ok); }
.st-vendido, .st-cerrado { background: var(--ok-bg); color: var(--ok); }
.st-devuelto, .st-defectuoso { background: var(--bad-bg); color: var(--bad); }
.st-en_disputa { background: #ffe4e6; color: #9f1239; }
html[data-tema="oscuro"] .st-en_disputa { background: #45101c; color: #fda4af; }

.lock-bloqueado, .lock-si, .lock-reportado { background: var(--bad-bg); color: var(--bad); }
.lock-libre, .lock-limpio, .lock-no { background: var(--ok-bg); color: var(--ok); }
.lock-desconocido, .lock-no_aplica { background: var(--bg-2); color: var(--muted); }

.hitos { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.hito {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--info);
}
.hito-ok { background: var(--ok-bg); color: var(--ok); }
.hito-warn { background: var(--warn-bg); color: var(--warn); }
.hito-mal { background: var(--bad-bg); color: var(--bad); }

/* --------------------------------------------------------------- alertas */

.flash {
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-weight: 600;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-left: 4px solid currentColor;
  animation: subir .35s var(--ease) both;
}
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--bad-bg); color: var(--bad); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.flash-info { background: var(--info-bg); color: var(--info); }

.alert-lock {
  background: var(--warn-bg);
  border: 1px solid #fdba74;
  border-left: 4px solid var(--warn);
  color: var(--warn);
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-weight: 650;
  font-size: 13.5px;
}

/* -------------------------------------------------------- compra segura */

.gate-box {
  display: grid;
  gap: 4px;
  background: linear-gradient(135deg, #fffbeb, #fff7ed);
  border: 1px solid #fcd34d;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
}
html[data-tema="oscuro"] .gate-box { background: #2c2408; border-color: #6b5510; }
.gate-box label { font-weight: 600; font-size: 13.5px; }
.gate-alerts .flash { margin-top: 8px; margin-bottom: 0; }

.rep-card {
  background: linear-gradient(135deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 18px;
  font-size: 13.5px;
}
.rep-negra { background: linear-gradient(135deg, #fff1f2, #ffe4e6); border-color: #fda4af; }
html[data-tema="oscuro"] .rep-negra { background: #3b1119; border-color: #7f1d2c; }

/* --------------------------------------------------------------- filtros */

.filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
  padding: 16px 18px;
}
.filters .field { margin-bottom: 0; }

/* ------------------------------------------------------------- detalles */

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 22px; }

.kv { padding: 9px 0; border-bottom: 1px dashed var(--line); }
.kv b {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 800;
  margin-bottom: 2px;
}
.kv span { font-size: 14.5px; font-weight: 550; }

.cost-box {
  background: linear-gradient(135deg, var(--navy), var(--navy-3));
  color: #fff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 10px 28px rgba(11, 31, 56, 0.25);
  position: relative;
  overflow: hidden;
}
.cost-box::before {
  content: "";
  position: absolute;
  top: -60px; right: -60px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.22), transparent 68%);
}
.cost-box .muted { color: #bed0e2; }
.cost-box strong { color: var(--gold-2); }
.cost-box .kv { border-bottom-color: rgba(255, 255, 255, 0.14); }
.cost-box .kv b { color: #a9c1d8; }

/* --------------------------------------------------------------- tooltip */

.tip-dot {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  cursor: help;
  flex: none;
  transition: background .16s var(--ease), color .16s var(--ease), transform .16s var(--ease);
}
.tip-dot:hover, .tip-dot:focus {
  background: var(--navy-3);
  color: #fff;
  transform: scale(1.15);
  outline: none;
}

#tooltip {
  position: fixed;
  z-index: 9999;
  max-width: 330px;
  background: linear-gradient(160deg, #142a47, #0b1f38);
  color: #eaf2fb;
  border: 1px solid rgba(212, 175, 55, 0.34);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12.8px;
  line-height: 1.55;
  box-shadow: 0 18px 46px rgba(3, 12, 26, 0.45);
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transition: opacity .16s var(--ease), transform .16s var(--ease);
}
#tooltip.visible { opacity: 1; transform: none; }
#tooltip .tt-title {
  display: block;
  font-weight: 800;
  font-size: 12.5px;
  color: var(--gold-2);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}
#tooltip .tt-hint {
  display: block;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 11px;
  color: #93a9c2;
}

body.sin-ayudas #tooltip { display: none; }

/* ----------------------------------------------------------------- toast */

#toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}
.toast {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--navy-3);
  border-radius: 12px;
  padding: 13px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: entraToast .35s var(--ease) both;
}
.toast.saliendo { animation: saleToast .3s var(--ease) forwards; }
.toast-ok { border-left-color: var(--ok); color: var(--ok); }
.toast-error { border-left-color: var(--bad); color: var(--bad); }
.toast-warn { border-left-color: var(--warn); color: var(--warn); }
.toast-info { border-left-color: var(--info); color: var(--info); }

@keyframes entraToast { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes saleToast { to { opacity: 0; transform: translateX(40px); height: 0; padding: 0; margin: 0; } }

/* --------------------------------------------------------------- pestañas */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 0;
}
.tab {
  border: 0;
  background: transparent;
  padding: 11px 15px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  border-radius: 8px 8px 0 0;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: color .16s var(--ease), background .16s var(--ease), border-color .16s var(--ease);
}
.tab:hover { color: var(--navy-3); background: var(--card-2); }
.tab.activo { color: var(--navy-3); border-bottom-color: var(--gold); }
html[data-tema="oscuro"] .tab.activo, html[data-tema="oscuro"] .tab:hover { color: #8ab8e8; }
.tab .tab-num {
  display: grid; place-items: center;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: var(--line);
  color: var(--muted);
  font-size: 10.5px; font-weight: 900;
}
.tab.activo .tab-num { background: var(--navy-3); color: #fff; }
.tab-panel { display: none; animation: aparecer .28s var(--ease) both; }
.tab-panel.activo { display: block; }

/* --------------------------------------------------------------- gráficos */

.chart-bars { display: grid; gap: 11px; }
.chart-row { display: grid; grid-template-columns: minmax(120px, 1.2fr) 1fr auto; align-items: center; gap: 12px; font-size: 13px; }
.chart-row .cr-label { color: var(--text); font-weight: 600; }
.chart-track { height: 9px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.chart-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--navy-4), var(--navy-3));
  width: 0;
  transition: width .9s var(--ease);
}
.chart-fill.f-gold { background: linear-gradient(90deg, var(--gold-2), var(--gold)); }
.chart-fill.f-ok { background: linear-gradient(90deg, #34d399, var(--ok)); }
.chart-fill.f-warn { background: linear-gradient(90deg, #fbbf24, var(--warn)); }
.chart-fill.f-bad { background: linear-gradient(90deg, #f87171, var(--bad)); }
.chart-row .cr-val { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); font-size: 12.5px; }

.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { width: 148px; height: 148px; flex: none; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 17; transition: stroke-dasharray 1s var(--ease); }
.donut-legend { display: grid; gap: 8px; font-size: 13px; flex: 1; min-width: 170px; }
.donut-legend div { display: flex; align-items: center; gap: 9px; }
.dot { width: 11px; height: 11px; border-radius: 3px; flex: none; }

.spark { display: flex; align-items: flex-end; gap: 3px; height: 46px; margin-top: 10px; }
.spark i {
  flex: 1;
  background: linear-gradient(180deg, var(--navy-4), rgba(47, 107, 163, 0.28));
  border-radius: 3px 3px 0 0;
  min-height: 3px;
  animation: crecer .7s var(--ease) both;
}
@keyframes crecer { from { transform: scaleY(0); transform-origin: bottom; } to { transform: none; } }

/* ---------------------------------------------------------------- varios */

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.empty {
  text-align: center;
  padding: 46px 18px;
  color: var(--muted);
  font-size: 14px;
}
.empty svg { width: 46px; height: 46px; opacity: 0.28; margin-bottom: 12px; }
.empty strong { display: block; color: var(--text); font-size: 15.5px; margin-bottom: 5px; }

.muted { color: var(--muted); }
.right { text-align: right; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.8px; letter-spacing: -0.2px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}

.contador-filtro { font-size: 12.5px; color: var(--muted); font-weight: 650; }

/* ----------------------------------------------------------- dashboard */

.dash-welcome {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.dash-welcome h2 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.6px;
  margin-bottom: 4px;
}
.dash-welcome p { color: var(--muted); max-width: 62ch; }

.dash-group {
  margin-bottom: 26px;
}
.dash-group-title {
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px 2px;
}

.dash-modules {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 0;
}
.dash-mod {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 16px 16px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  min-height: 148px;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s var(--ease);
  animation: subir .45s var(--ease) both;
}
.dash-mod:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: rgba(47, 107, 163, 0.35);
  color: var(--text);
}
.dash-mod-ico {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(31, 78, 121, 0.12), rgba(212, 175, 55, 0.14));
  color: var(--navy-3);
  border: 1px solid rgba(31, 78, 121, 0.08);
}
html[data-tema="oscuro"] .dash-mod-ico {
  background: linear-gradient(145deg, rgba(138, 184, 232, 0.12), rgba(212, 175, 55, 0.12));
  color: #8ab8e8;
}
.dash-mod-ico svg { width: 22px; height: 22px; }
.dash-mod strong {
  display: block;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.2px;
  margin-bottom: 4px;
}
.dash-mod span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}
.dash-mod-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy-3);
}
html[data-tema="oscuro"] .dash-mod-foot { color: #8ab8e8; }
.dash-mod-stat {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 650;
}
@media (max-width: 1100px) {
  .dash-modules { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .dash-modules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-welcome h2 { font-size: 22px; }
}
@media (max-width: 480px) {
  .dash-modules { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------ responsive */

/* El encabezado se va compactando por etapas: primero el subtítulo,
   después el texto del menú, y solo al final pasa a dos filas. */

@media (max-width: 1360px) {
  .brand small { display: none; }
  .search-box input { width: 160px; }
}

@media (max-width: 1200px) {
  .nav-item { min-width: 58px; padding: 7px 8px; }
  .nav-label { font-size: 10px; max-width: 64px; }
  .nav-ico { width: 30px; height: 30px; border-radius: 9px; }
  .nav-item svg { width: 16px; height: 16px; }
}

@media (max-width: 900px) {
  .brand h1 { display: none; }
  .brand-logo { width: 42px; height: 42px; }
  .search-box input { width: 130px; }
  .search-box input:focus { width: 190px; }
  .nav-label { display: none; }
  .nav-item { min-width: 48px; padding: 8px; }
}

@media (max-width: 760px) {
  .app-header { padding: 8px 14px; }
  .header-inner { flex-wrap: wrap; min-height: 0; row-gap: 8px; }
  .brand { order: 1; }
  .header-tools { order: 2; margin-left: auto; }
  .nav { order: 3; width: 100%; justify-content: space-between; }
  .brand h1 { display: block; }
  .search-box input { width: 100%; min-width: 120px; }
}

@media (max-width: 980px) {
  .two, .form-grid, .form-grid-3, .filters, .detail-grid { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
  .wrap { padding: 18px 14px 44px; }
  .chart-row { grid-template-columns: 1fr; gap: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media print {
  .app-header, .btn, .filters, #toasts, #tooltip { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  body { background: #fff; }
}
