:root {
  --bg: #0e1016;
  --bg-2: #151922;
  --bg-3: #1b2029;
  --linea: #262c38;
  --linea-2: #333b49;
  --txt: #e9ecf3;
  --txt-2: #9aa3b2;
  --txt-3: #6b7484;
  --azul: #3b82f6;
  --azul-2: #2563eb;
  --verde: #22c55e;
  --ambar: #f59e0b;
  --rojo: #ef4444;
  --morado: #8b5cf6;
  --r: 12px;
  --sombra: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: #8fb4ff; }

.oculto { display: none !important; }

/* ---------- cabecera ---------- */

header.top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(14, 16, 22, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--linea);
}

.top-in {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.marca { display: flex; align-items: center; gap: 11px; margin-right: auto; }

.marca .logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--azul), var(--morado));
  display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #fff;
  letter-spacing: -.5px;
}

.marca h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.marca .sub { font-size: 12px; color: var(--txt-3); }

nav.tabs { display: flex; gap: 4px; background: var(--bg-2); padding: 4px; border-radius: 10px; }

nav.tabs button {
  background: transparent; border: 0; color: var(--txt-2);
  padding: 8px 15px; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
nav.tabs button:hover { color: var(--txt); }
nav.tabs button.on { background: var(--bg-3); color: var(--txt); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }

/* ---------- contenido ---------- */

main { max-width: 1280px; margin: 0 auto; padding: 22px 20px 80px; }

.aviso {
  display: flex; gap: 12px; align-items: flex-start;
  background: rgba(245, 158, 11, .1);
  border: 1px solid rgba(245, 158, 11, .35);
  color: #fcd9a0; padding: 13px 16px; border-radius: var(--r);
  margin-bottom: 20px; font-size: 14px;
}
.aviso b { color: #fde9c8; }
.aviso .ico { font-size: 17px; line-height: 1.2; }

/* ---------- tarjetas de estadistica ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }

.stat {
  background: var(--bg-2); border: 1px solid var(--linea);
  border-radius: var(--r); padding: 15px 17px;
}
.stat .n { font-size: 27px; font-weight: 800; letter-spacing: -1px; }
.stat .l { font-size: 12.5px; color: var(--txt-2); margin-top: 2px; }
.stat.verde .n { color: var(--verde); }
.stat.ambar .n { color: var(--ambar); }
.stat.azul .n { color: #60a5fa; }

/* ---------- asignacion rapida ---------- */

.rapida {
  background: linear-gradient(135deg, rgba(59, 130, 246, .12), rgba(139, 92, 246, .08));
  border: 1px solid rgba(59, 130, 246, .3);
  border-radius: 16px; padding: 18px 20px; margin-bottom: 22px;
}
.rapida h2 { margin: 0 0 3px; font-size: 16px; }
.rapida p { margin: 0 0 14px; font-size: 13.5px; color: var(--txt-2); }
.rapida .campos { display: grid; grid-template-columns: 150px 1fr 1fr auto; gap: 10px; }
@media (max-width: 860px) { .rapida .campos { grid-template-columns: 1fr; } }

/* ---------- controles ---------- */

input[type=text], input[type=url], input[type=password], input[type=number], select, textarea {
  width: 100%; background: var(--bg-3); border: 1px solid var(--linea-2);
  color: var(--txt); border-radius: 10px; padding: 10px 12px;
  font-size: 14px; font-family: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--azul); box-shadow: 0 0 0 3px rgba(59, 130, 246, .18); }
input::placeholder, textarea::placeholder { color: var(--txt-3); }
textarea { resize: vertical; min-height: 72px; }
select { cursor: pointer; }
.mono { font-family: ui-monospace, Consolas, "Courier New", monospace; letter-spacing: 1.5px; text-transform: uppercase; }

label.campo { display: block; margin-bottom: 12px; }
label.campo > span { display: block; font-size: 12.5px; color: var(--txt-2); margin-bottom: 5px; font-weight: 600; }
label.campo small { display: block; color: var(--txt-3); font-size: 11.5px; margin-top: 5px; font-weight: 400; }

.btn {
  background: var(--bg-3); color: var(--txt); border: 1px solid var(--linea-2);
  border-radius: 10px; padding: 10px 15px; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { border-color: #465062; background: #232a36; }
.btn.pri { background: var(--azul); border-color: var(--azul); color: #fff; }
.btn.pri:hover { background: var(--azul-2); border-color: var(--azul-2); }
.btn.ok { background: var(--verde); border-color: var(--verde); color: #05230f; }
.btn.peligro { color: #ffb4b4; border-color: rgba(239, 68, 68, .4); }
.btn.peligro:hover { background: rgba(239, 68, 68, .15); border-color: var(--rojo); }
.btn.chico { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- barra de herramientas ---------- */

.herramientas { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.herramientas .buscar { flex: 1 1 240px; min-width: 200px; }
.herramientas select { width: auto; min-width: 130px; }
.sep { flex-basis: 100%; height: 0; }

/* ---------- tabla ---------- */

.tabla-caja { background: var(--bg-2); border: 1px solid var(--linea); border-radius: var(--r); overflow: hidden; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 11px 14px; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--txt-3); background: var(--bg-3);
  border-bottom: 1px solid var(--linea); font-weight: 700; white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--linea); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, .022); }

.cod-cel { font-family: ui-monospace, Consolas, monospace; font-weight: 700; letter-spacing: 1.5px; font-size: 14px; }
.cod-cel .lote { display: block; font-family: system-ui; font-weight: 400; letter-spacing: 0; font-size: 11px; color: var(--txt-3); }

.destino-cel { max-width: 340px; }
.destino-cel a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.vacio { color: var(--txt-3); font-style: italic; font-size: 13px; }

.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.pill.libre { background: rgba(245, 158, 11, .15); color: #fbbf24; }
.pill.activo { background: rgba(34, 197, 94, .15); color: #4ade80; }
.pill.off { background: rgba(239, 68, 68, .15); color: #f87171; }

.acciones { display: flex; gap: 6px; justify-content: flex-end; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

.sin-datos { padding: 50px 20px; text-align: center; color: var(--txt-3); }
.sin-datos .big { font-size: 30px; margin-bottom: 8px; }

.paginacion { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 14px; color: var(--txt-2); font-size: 13.5px; }

/* ---------- lotes ---------- */

.lotes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.lote-card { background: var(--bg-2); border: 1px solid var(--linea); border-radius: var(--r); padding: 17px; }
.lote-card h3 { margin: 0 0 4px; font-size: 15px; font-family: ui-monospace, Consolas, monospace; }
.lote-card .meta { font-size: 13px; color: var(--txt-2); margin-bottom: 12px; }
.barra-prog { height: 6px; background: var(--bg-3); border-radius: 99px; overflow: hidden; margin: 10px 0 12px; }
.barra-prog i { display: block; height: 100%; background: var(--verde); }
.lote-card .btns { display: flex; gap: 7px; flex-wrap: wrap; }

/* ---------- paneles de contenido ---------- */

.panel { background: var(--bg-2); border: 1px solid var(--linea); border-radius: var(--r); padding: 22px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 4px; font-size: 17px; }
.panel > p.desc { margin: 0 0 18px; color: var(--txt-2); font-size: 13.5px; }
.dos-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
@media (max-width: 720px) { .dos-col { grid-template-columns: 1fr; } }

.pasos { counter-reset: p; padding: 0; margin: 0; list-style: none; }
.pasos li { counter-increment: p; position: relative; padding-left: 42px; margin-bottom: 18px; }
.pasos li::before {
  content: counter(p); position: absolute; left: 0; top: -1px;
  width: 28px; height: 28px; border-radius: 8px; background: var(--bg-3);
  border: 1px solid var(--linea-2); display: grid; place-items: center;
  font-weight: 800; font-size: 13px; color: #8fb4ff;
}
.pasos li b { display: block; margin-bottom: 3px; }
.pasos li p { margin: 0; color: var(--txt-2); font-size: 13.5px; }

code.inline { background: var(--bg-3); border: 1px solid var(--linea-2); border-radius: 6px; padding: 2px 6px; font-size: 12.5px; font-family: ui-monospace, Consolas, monospace; }

/* ---------- modal ---------- */

.velo {
  position: fixed; inset: 0; background: rgba(5, 7, 11, .72);
  display: grid; place-items: center; z-index: 60; padding: 20px; backdrop-filter: blur(3px);
}
.modal {
  background: var(--bg-2); border: 1px solid var(--linea-2); border-radius: 16px;
  width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; box-shadow: var(--sombra);
}
.modal.ancho { max-width: 720px; }
.modal header { padding: 18px 22px; border-bottom: 1px solid var(--linea); display: flex; align-items: center; gap: 12px; }
.modal header h2 { margin: 0; font-size: 17px; flex: 1; }
.modal header .x { background: transparent; border: 0; color: var(--txt-3); font-size: 22px; cursor: pointer; line-height: 1; padding: 0 4px; }
.modal .cuerpo { padding: 22px; }
.modal footer { padding: 16px 22px; border-top: 1px solid var(--linea); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.modal footer .izq { margin-right: auto; }

.qr-vista { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; }
.qr-vista .marco { background: #fff; padding: 10px; border-radius: 12px; width: 148px; height: 148px; flex: 0 0 auto; }
.qr-vista .marco img { width: 100%; height: 100%; display: block; }
.qr-vista .datos { flex: 1; min-width: 200px; }
.qr-vista .datos .cod { font-family: ui-monospace, Consolas, monospace; font-size: 24px; font-weight: 800; letter-spacing: 3px; }
.qr-vista .datos .url { font-size: 12.5px; color: var(--txt-2); word-break: break-all; margin: 6px 0 12px; }
.qr-vista .datos .btns { display: flex; gap: 7px; flex-wrap: wrap; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch i { width: 40px; height: 23px; border-radius: 99px; background: var(--linea-2); position: relative; transition: background .15s; flex: 0 0 auto; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--verde); }
.switch input:checked + i::after { transform: translateX(17px); }

/* ---------- avisos flotantes ---------- */

#toasts { position: fixed; bottom: 22px; right: 22px; z-index: 90; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--bg-3); border: 1px solid var(--linea-2); border-left: 3px solid var(--azul);
  border-radius: 10px; padding: 12px 17px; font-size: 14px; box-shadow: var(--sombra);
  max-width: 380px; animation: entra .18s ease;
}
.toast.ok { border-left-color: var(--verde); }
.toast.err { border-left-color: var(--rojo); }
@keyframes entra { from { opacity: 0; transform: translateY(8px); } }

/* ---------- login ---------- */

body.login { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-caja { width: 100%; max-width: 380px; background: var(--bg-2); border: 1px solid var(--linea); border-radius: 18px; padding: 34px 30px; box-shadow: var(--sombra); }
.login-caja .logo { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg, var(--azul), var(--morado)); display: grid; place-items: center; font-weight: 800; color: #fff; margin: 0 auto 16px; }
.login-caja h1 { font-size: 20px; margin: 0 0 6px; text-align: center; }
.login-caja p { margin: 0 0 22px; text-align: center; color: var(--txt-2); font-size: 13.5px; }
.login-caja .btn { width: 100%; justify-content: center; margin-top: 6px; }
.error-login { color: #f87171; font-size: 13.5px; text-align: center; margin-top: 12px; min-height: 20px; }

@media (max-width: 700px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  thead th.opc, tbody td.opc { display: none; }
  main { padding: 16px 12px 60px; }
  .top-in { padding: 12px; }
}
