/* Opportunity Hunter — estilos. Tema claro/oscuro con variables CSS. */
:root {
  --bg: #f4f6f8; --panel: #ffffff; --text: #14181d; --muted: #5f6b7a;
  --line: #e3e8ee; --chip: #eef2f6; --hover: #f7f9fb;
  --brand: #0f766e; --brand-ink: #ffffff; --brand-soft: #d9f2ee;
  --warn: #b42318; --warn-bg: #fdecea;
  --amber: #8a5a00; --amber-bg: #fdf1d6;
  --pos: #067647;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1013; --panel: #161a1f; --text: #e8ebef; --muted: #98a2b3;
    --line: #252b33; --chip: #1f252c; --hover: #1a1f25;
    --brand: #2dd4bf; --brand-ink: #04211d; --brand-soft: #123530;
    --warn: #ff9b8f; --warn-bg: #3a1714;
    --amber: #f0cc70; --amber-bg: #2e2810;
    --pos: #5fd39a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1013; --panel: #161a1f; --text: #e8ebef; --muted: #98a2b3;
  --line: #252b33; --chip: #1f252c; --hover: #1a1f25;
  --brand: #2dd4bf; --brand-ink: #04211d; --brand-soft: #123530;
  --warn: #ff9b8f; --warn-bg: #3a1714;
  --amber: #f0cc70; --amber-bg: #2e2810;
  --pos: #5fd39a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1rem; margin: 0 0 .75rem; }
h3 { font-size: .85rem; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
code, kbd { font: .85em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--chip); border-radius: 6px; padding: 1px 6px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 24px; padding-bottom: 48px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.strong { font-weight: 650; }
.pos { color: var(--pos); }
.neg { color: var(--warn); }
.skip { position: absolute; left: -999px; top: 0; background: var(--brand); color: var(--brand-ink); padding: 8px 14px; border-radius: 0 0 8px 0; z-index: 100; }
.skip:focus { left: 0; }

/* ---- Barra superior ---- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; gap: 20px; height: 58px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo { color: var(--brand); font-size: 1.35rem; line-height: 1; }
nav { flex: 1; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav a { padding: 7px 13px; border-radius: 9px; color: var(--muted); font-weight: 550; white-space: nowrap; }
nav a:hover { background: var(--chip); color: var(--text); text-decoration: none; }
nav a.on { background: var(--brand-soft); color: var(--brand); }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); white-space: nowrap; }
.who form { margin: 0; }
.role { background: var(--chip); padding: 1px 9px; border-radius: 999px; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
button.link { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; font-weight: 600; }
.icon-btn { background: var(--chip); border: 1px solid var(--line); color: var(--text); width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 1rem; line-height: 1; }
.icon-btn:hover { border-color: var(--brand); }

/* ---- Tarjetas y encabezados ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 18px; }
.crumbs { margin: 0 0 10px; }

/* ---- Botones y formularios ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--brand); color: var(--brand-ink); border: 1px solid var(--brand); border-radius: 10px; padding: 8px 15px; font: inherit; font-weight: 650; cursor: pointer; transition: filter .15s, background .15s; }
.btn:hover { text-decoration: none; filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); filter: none; }
.btn.sm { padding: 3px 11px; font-size: .82rem; border-radius: 8px; }
.btn.danger { color: var(--warn); border-color: var(--warn); }
.btn.danger:hover { background: var(--warn-bg); }
.btn.block { width: 100%; }
form.inline { display: inline; margin: 0; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
textarea { resize: vertical; width: 100%; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px; }
.filters input[type=search] { flex: 1 1 240px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.form input, .form textarea { font-weight: 400; }
.form.compact { gap: 10px; margin-bottom: 16px; }
.form.compact label { font-size: .88rem; }
fieldset.deal { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; margin: 0; }
fieldset.deal legend { color: var(--muted); font-size: .78rem; padding: 0 6px; text-transform: uppercase; letter-spacing: .05em; }
.profit { margin: 0; }

/* ---- Chips, avisos, mensajes ---- */
.chip { display: inline-block; background: var(--chip); border-radius: 999px; padding: 2px 11px; font-size: .8rem; white-space: nowrap; color: var(--text); }
a.chip:hover { text-decoration: none; filter: brightness(.96); }
.chip.on { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.chip.warn { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chips .chip { padding: 5px 14px; border: 1px solid var(--line); background: var(--panel); }
.chips .chip.on { border-color: var(--brand); background: var(--brand-soft); }
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; }
.notice { background: var(--amber-bg); color: var(--amber); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
.notice a { color: inherit; text-decoration: underline; }
.alert { background: var(--warn-bg); color: var(--warn); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
.alert a { color: inherit; text-decoration: underline; }
ul.plain { margin: 6px 0 0; padding-left: 18px; }
.flash { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--brand-soft); color: var(--brand); border-radius: 12px; padding: 10px 14px; margin-bottom: 16px; font-weight: 600; transition: opacity .4s, transform .4s; }
.flash.hide { opacity: 0; transform: translateY(-6px); pointer-events: none; height: 0; padding: 0; margin: 0; overflow: hidden; }
.flash-x { background: none; border: 0; color: inherit; font-size: 1.3rem; line-height: 1; cursor: pointer; }

/* ---- Cuenta regresiva y urgencia ---- */
.cd { font-variant-numeric: tabular-nums; white-space: nowrap; }
.u-warm { color: var(--amber); font-weight: 650; }
.u-hot { color: var(--warn); font-weight: 700; }

/* ---- Panel ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); color: var(--text); transition: border-color .15s, transform .15s; }
.kpi:hover { text-decoration: none; border-color: var(--brand); transform: translateY(-1px); }
.kpi .label { color: var(--muted); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 2rem; font-weight: 750; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi.hot .value { color: var(--warn); }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.rows .empty-row { color: var(--muted); justify-content: center; padding: 22px 0; }
.biz { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.biz:last-child { border-bottom: 0; }
.onboarding { border-style: dashed; }

/* ---- Tablas ---- */
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); white-space: nowrap; background: color-mix(in srgb, var(--chip) 45%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--hover); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 44px 14px; }
.big-icon { font-size: 2rem; margin-bottom: 6px; }
.veh { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.thumb { width: 64px; height: 46px; border-radius: 9px; object-fit: cover; background: var(--chip); flex: none; }
.thumb.ph { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); font-size: 1.3rem; }
.verdict { display: inline-block; border-radius: 999px; padding: 2px 11px; font-size: .78rem; white-space: nowrap; }
.verdict.pending { background: var(--chip); color: var(--muted); }
.pager { display: flex; gap: 10px; justify-content: center; margin-top: 4px; }
table.mini th, table.mini td { padding: 7px 8px; }

/* ---- Ficha del lote ---- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.col { display: flex; flex-direction: column; min-width: 0; }
.hero { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; }
.eyebrow { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.hero-side { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }
.stat-block { display: flex; flex-direction: column; gap: 2px; }
.stat-block .label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.stat-block .big { font-size: 1.7rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.spark { width: 120px; height: 32px; margin-top: 4px; }
.spark polyline { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.facts { display: grid; grid-template-columns: 150px 1fr; gap: 9px 12px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.placeholder { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 12px; margin-bottom: 10px; }
.placeholder:last-child { margin-bottom: 0; }
.desc { white-space: pre-wrap; font: inherit; margin: 0; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.photos img { width: 100%; height: 160px; object-fit: cover; border-radius: 10px; background: var(--chip); }
.timeline { list-style: none; margin: 0 0 16px; padding: 0; border-left: 2px solid var(--line); }
.timeline li { padding: 4px 0 9px 16px; display: flex; flex-direction: column; gap: 1px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 9px; width: 12px; height: 12px; border-radius: 50%; background: var(--line); border: 2px solid var(--panel); }
.timeline li.ev-note::before { background: var(--brand); }
.timeline li.ev-stage::before { background: var(--amber); }
.timeline li.ev-deal::before { background: var(--pos); }
.timeline .when { color: var(--muted); font-size: .78rem; }

/* ---- Seguimiento: resumen y tablero ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 4px; }
.stat { margin-bottom: 0; display: flex; flex-direction: column; gap: 4px; }
.seg { display: inline-flex; background: var(--chip); border-radius: 10px; padding: 3px; }
.seg a { padding: 4px 14px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: .88rem; }
.seg a.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.seg a:hover { text-decoration: none; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 8px; }
.bcol { background: color-mix(in srgb, var(--chip) 60%, transparent); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 140px; }
.bcol header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 2px 4px; }
.bcol .count { background: var(--panel); border-radius: 999px; padding: 0 9px; font-size: .78rem; }
.kcard { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.kline { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; width: 100%; }
.bempty { color: var(--muted); text-align: center; font-size: .85rem; padding: 18px 0; }

/* ---- Login y estados vacíos ---- */
.login { max-width: 390px; margin: 9vh auto 0; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 6px; }
.logo-big { color: var(--brand); font-size: 2.2rem; line-height: 1; }
.empty-state { text-align: center; padding: 70px 0; }
.foot { color: var(--muted); font-size: .8rem; padding-bottom: 28px; }

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .grid2 { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
  .uname { display: none; }
}
@media (max-width: 720px) {
  .wrap { padding: 0 14px; }
  .bar { gap: 10px; }
  .brand span:last-child { display: none; }
  /* Las tablas "stack" se vuelven tarjetas apiladas */
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; text-align: left; }
  table.stack td.main { display: block; text-align: left; padding-bottom: 6px; }
  table.stack td.main::before { content: none; }
  table.stack td.empty { display: block; text-align: center; }
  table.stack td.empty::before { content: none; }
  .facts { grid-template-columns: 120px 1fr; }
}
@media print {
  .topbar, .foot, .btn, .filters, .chips, form { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; }
}
