:root {
  --bg: #f2f5f9;
  --card: #ffffff;
  --ink: #16212e;
  --muted: #67748a;
  --line: #e4e9f0;
  --brand: #0d4a7d;
  --brand-2: #1769aa;
  --brand-soft: #e8f1f9;
  --accent: #e07b00;
  --accent-soft: #fdf1e0;
  --ok: #15803d;
  --ok-soft: #e6f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --bad: #dc2626;
  --bad-soft: #fdeaea;
  --radius: 16px;
  --shadow-1: 0 1px 2px rgba(15, 30, 55, .06), 0 2px 8px rgba(15, 30, 55, .05);
  --shadow-2: 0 4px 10px rgba(15, 30, 55, .08), 0 12px 32px rgba(15, 30, 55, .10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid rgba(23, 105, 170, .45); outline-offset: 2px; border-radius: 6px; }

/* ================= Cabecera ================= */
header.top {
  background: linear-gradient(115deg, #0a3a63 0%, var(--brand) 45%, var(--brand-2) 100%);
  color: #fff;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  box-shadow: 0 2px 14px rgba(10, 45, 80, .28);
  position: sticky;
  top: 0;
  z-index: 50;
}
header.top h1 { font-size: 18px; margin: 0; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; }
header.top h1 a { color: #fff; }
header.top h1 a:hover { text-decoration: none; opacity: .92; }
header.top .spacer { flex: 1; }
header.top .meta { font-size: 12px; opacity: .8; }

/* Navegación tipo píldora */
header.top .navtop {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, .13);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  padding: 4px;
}
header.top .navtop a {
  color: #fff;
  padding: 7px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
header.top .navtop a:hover { background: rgba(255, 255, 255, .16); text-decoration: none; }
header.top .navtop a.activo {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .22);
}
header.top .btn-salir {
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .4);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s ease, border-color .15s ease;
}
header.top .btn-salir:hover { background: rgba(255, 255, 255, .15); border-color: rgba(255,255,255,.7); text-decoration: none; }

.wrap { max-width: 1300px; margin: 0 auto; padding: 22px 22px 48px; }

/* ================= Resumen ================= */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 18px;
  box-shadow: var(--shadow-1);
  min-width: 148px;
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--brand-2);
  border-radius: 4px 0 0 4px;
}
.stat:nth-child(2)::before { background: #2563eb; }
.stat:nth-child(3)::before { background: var(--bad); }
.stat:nth-child(4)::before { background: var(--accent); }
.stat b { display: block; font-size: 22px; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 12px; font-weight: 600; }

/* ================= Filtros ================= */
form.filtros {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-1);
  margin-bottom: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 12px;
}
form.filtros label {
  font-size: 11px; color: var(--muted); display: block; margin-bottom: 5px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}
form.filtros input, form.filtros select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: #fbfcfe;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  appearance: auto;
}
form.filtros input:hover, form.filtros select:hover { border-color: #c9d4e2; }
form.filtros input:focus, form.filtros select:focus {
  outline: none;
  border-color: var(--brand-2);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(23, 105, 170, .14);
}
form.filtros .acciones { display: flex; align-items: end; gap: 8px; }

.btn {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  border: 0;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: .01em;
  box-shadow: 0 2px 6px rgba(13, 74, 125, .3);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(13, 74, 125, .38); filter: brightness(1.05); }
.btn:active { transform: translateY(0); }
.btn.sec {
  background: var(--brand-soft);
  color: var(--brand);
  border: 1.5px solid transparent;
  box-shadow: none;
}
.btn.sec:hover { border-color: var(--brand-2); filter: none; }

.resumen-linea { color: var(--muted); margin: 0 0 14px; font-size: 13.5px; font-weight: 600; }

/* ================= Tarjetas ================= */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(315px, 1fr)); gap: 18px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: inherit;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-2);
  border-color: #cfdae7;
  text-decoration: none;
}
.card .foto {
  height: 165px;
  background: linear-gradient(150deg, #dfe9f3 0%, #eef3f9 60%, #e4edf6 100%) center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.card .foto > span { font-size: 54px; filter: grayscale(.15); opacity: .85; transition: transform .2s ease; }
.card:hover .foto > span { transform: scale(1.08); }
.card .foto::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10, 30, 55, .35) 0%, rgba(10, 30, 55, 0) 45%);
  pointer-events: none;
}
.card .foto .badges { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 6px; flex-wrap: wrap; z-index: 1; }
.badge {
  font-size: 11px; font-weight: 700; padding: 4px 11px; border-radius: 999px;
  color: #fff; letter-spacing: .02em; line-height: 1.2;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}
.st-ej { background: var(--ok); }
.st-pu { background: #2563eb; }
.st-su, .st-ca { background: var(--bad); }
.st-pc { background: #6b7280; }
.badge.origen { background: rgba(13, 55, 95, .92); }
.badge.fuego { background: linear-gradient(135deg, #f59e0b, #e2540a); }

.card .cuerpo { padding: 15px 17px 13px; flex: 1; display: flex; flex-direction: column; gap: 7px; }
.card .lugar { font-weight: 800; font-size: 16px; letter-spacing: -.01em; display: flex; gap: 7px; align-items: baseline; }
.card .lugar .prov { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.card .desc {
  color: var(--muted); font-size: 12.8px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.6em;
}

.card .precio-linea { display: flex; align-items: baseline; gap: 9px; margin-top: 3px; flex-wrap: wrap; }
.card .precio-linea .precio { font-size: 21px; font-weight: 800; letter-spacing: -.02em; color: var(--brand); }
.card .precio-linea .precio.viva { color: var(--accent); }
.card .precio-linea s { color: var(--muted); font-size: 13px; }
.card .precio-linea .etiq { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

.card .mini-datos {
  display: flex; gap: 0; margin-top: auto; padding-top: 10px; border-top: 1px dashed var(--line);
}
.card .mini-datos .dato { flex: 1; min-width: 0; }
.card .mini-datos .dato + .dato { border-left: 1px dashed var(--line); padding-left: 12px; }
.card .mini-datos span { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.card .mini-datos b { font-size: 13.5px; font-weight: 700; }

.card .pie {
  padding: 10px 17px 12px;
  display: flex; justify-content: space-between; align-items: center; font-size: 12.5px;
  gap: 8px;
}
.cd-pill { padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: 12px; white-space: nowrap; }
.cd-urgent { background: var(--bad-soft); color: var(--bad); animation: pulso 1.6s ease-in-out infinite; }
.cd-soon { background: var(--warn-soft); color: var(--warn); }
.cd-ok { background: var(--ok-soft); color: var(--ok); }
.cd-off { background: #eef1f5; color: var(--muted); }
@keyframes pulso { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.card .fecha-fin { color: var(--muted); font-weight: 600; }

/* Barra de progreso temporal de la subasta */
.tbar { height: 4px; background: #edf1f6; width: 100%; }
.tbar i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--brand-2), var(--brand));
  border-radius: 0 4px 4px 0;
  transition: width .3s ease;
}
.tbar.t-soon i { background: linear-gradient(90deg, #f59e0b, #e07b00); }
.tbar.t-urgent i { background: linear-gradient(90deg, #f87171, var(--bad)); }

/* ================= Paginación ================= */
.paginacion { display: flex; gap: 7px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.paginacion a, .paginacion span {
  min-width: 40px; text-align: center;
  padding: 8px 13px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--card); font-size: 14px; font-weight: 600;
  transition: border-color .15s ease, transform .15s ease;
}
.paginacion a:hover { border-color: var(--brand-2); text-decoration: none; transform: translateY(-1px); }
.paginacion span.actual { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 2px 6px rgba(13,74,125,.3); }

/* ================= Detalle ================= */
.volver { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 16px; font-size: 14px; font-weight: 600; }
.detalle-cab { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); padding: 22px; margin-bottom: 18px; }
.detalle-cab h2 { margin: 0 0 6px; font-size: 21px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; letter-spacing: -.01em; }
.detalle-cab .sub { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 8px; }
.kpi { background: var(--bg); border-radius: 12px; padding: 11px 15px; border: 1px solid transparent; }
.kpi span { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.kpi b { font-size: 17px; letter-spacing: -.01em; }
.kpi.destacado { background: var(--accent-soft); border-color: #f6ddb7; }
.kpi.destacado b { color: var(--accent); }

.seccion { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); padding: 20px 22px; margin-bottom: 18px; }
.seccion h3 { margin: 0 0 14px; font-size: 16px; color: var(--brand); letter-spacing: -.01em; }
table.props { width: 100%; border-collapse: collapse; font-size: 14px; }
table.props th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 14px 8px 0; vertical-align: top; width: 210px; }
table.props td { padding: 8px 0; }
table.props tr + tr { border-top: 1px solid var(--line); }

.enlaces { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.enlaces a {
  border: 1.5px solid var(--line); background: #fbfcfe; padding: 8px 15px;
  border-radius: 10px; font-size: 13.5px; font-weight: 700; color: var(--brand);
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.enlaces a:hover { background: var(--brand-soft); border-color: var(--brand-2); text-decoration: none; transform: translateY(-1px); }

.galeria { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.galeria img { height: 130px; border-radius: 10px; border: 1px solid var(--line); box-shadow: var(--shadow-1); }

/* ================= Login ================= */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0a3a63, var(--brand) 55%, var(--brand-2)); }
.login-box { background: #fff; border-radius: 18px; padding: 36px 34px; width: 350px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.login-box h1 { font-size: 21px; margin: 0 0 4px; color: var(--brand); }
.login-box p { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; }
.login-box label { font-size: 12px; font-weight: 700; color: var(--muted); display: block; margin: 14px 0 5px; text-transform: uppercase; letter-spacing: .04em; }
.login-box input { width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 10px; font-size: 15px; transition: border-color .15s ease, box-shadow .15s ease; }
.login-box input:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(23, 105, 170, .15); }
.login-box .btn { width: 100%; margin-top: 20px; padding: 12px; }
.login-error { background: var(--bad-soft); color: #991b1b; padding: 10px 13px; border-radius: 10px; font-size: 13.5px; margin-bottom: 6px; }

/* ================= Avisos ================= */
.vacio {
  text-align: center; color: var(--muted); padding: 70px 20px;
  background: var(--card); border: 1.5px dashed var(--line); border-radius: var(--radius);
  font-size: 15px;
}
.aviso-scraper { background: var(--warn-soft); border: 1px solid #f3ddb0; color: #92400e; border-radius: 12px; padding: 11px 15px; font-size: 13.5px; margin-bottom: 16px; }
.puja-viva { color: var(--accent); }
.pujas-aviso { border-radius: 10px; padding: 10px 13px; font-size: 13.5px; margin: 0 0 12px; }
.pujas-aviso.ok { background: var(--ok-soft); color: #166534; }
.pujas-aviso.mal { background: var(--bad-soft); color: #991b1b; }

/* ================= Oportunidades ================= */
.lista-op { display: flex; flex-direction: column; gap: 13px; }
.op-fila {
  display: flex; gap: 18px; align-items: stretch; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-1); padding: 16px 18px;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.op-fila:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: #cfdae7; text-decoration: none; }
.op-score {
  min-width: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 14px; padding: 10px; align-self: center;
}
.op-score b { font-size: 27px; line-height: 1; letter-spacing: -.02em; }
.op-score span { font-size: 11px; opacity: .7; font-weight: 700; }
.sc-alto { background: var(--ok-soft); color: #166534; box-shadow: inset 0 0 0 1.5px #b7e3c5; }
.sc-medio { background: var(--warn-soft); color: #92400e; box-shadow: inset 0 0 0 1.5px #f0dcae; }
.sc-bajo { background: #f1f5f9; color: #475569; }
.sc-na { background: #f1f5f9; color: #94a3b8; }
.op-main { flex: 1; min-width: 0; }
.op-titulo { font-weight: 800; font-size: 15.5px; margin-bottom: 3px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; letter-spacing: -.01em; }
.op-desc { color: var(--muted); font-size: 13px; margin-bottom: 9px; }
.op-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 4px 11px; border-radius: 999px; font-weight: 600; line-height: 1.3; }
.chip-desc { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 700; }
.chip-ok { background: var(--ok-soft); color: #166534; }
.chip-warn { background: var(--warn-soft); color: #92400e; }
.op-datos { display: flex; flex-direction: column; gap: 6px; min-width: 195px; font-size: 13px; text-align: right; justify-content: center; }
.op-datos span { color: var(--muted); font-size: 10.5px; display: block; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.op-datos b { font-size: 14.5px; }

@media (max-width: 720px) {
  .wrap { padding: 14px 13px 34px; }
  header.top { padding: 10px 14px; gap: 10px; }
  header.top .navtop a { padding: 7px 13px; }
  header.top .meta { display: none; }
  table.props th { width: 130px; }
  .op-fila { flex-wrap: wrap; }
  .op-score { align-self: flex-start; }
  .op-datos { flex-direction: row; flex-wrap: wrap; gap: 14px; min-width: 0; text-align: left; }
}
