/* InmoPujas — consola de captación. Sistema de diseño "blueprint de mercado". */
:root {
  --ink: #0f1a24;
  --ink-deep: #0a1119;
  --surface: #16232f;
  --surface-2: #1c2e3c;
  --line: #263b4c;
  --line-soft: #1f303e;
  --brass: #c89b3c;
  --brass-bright: #e0b551;
  --brass-soft: rgba(200, 155, 60, 0.14);
  --signal: #3fb98a;
  --warn: #e08636;
  --danger: #e5604d;
  --text: #e6edf2;
  --muted: #8397a6;
  --muted-2: #5c7284;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.6);
  --font-display: 'Archivo', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Login ---------- */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(200, 155, 60, 0.08), transparent 60%),
    linear-gradient(180deg, var(--ink) 0%, var(--ink-deep) 100%);
  position: relative;
  overflow: hidden;
}
/* rejilla tipo plano/blueprint */
.login::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(900px 500px at 50% 40%, #000 30%, transparent 75%);
  opacity: 0.5;
}
.login__card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 34px 32px 30px;
  box-shadow: var(--shadow);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}
.brand__mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--brass-soft);
  border: 1px solid rgba(200, 155, 60, 0.4);
  color: var(--brass-bright);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
}
.brand__name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
}
.brand__name b { color: var(--brass-bright); font-weight: 800; }
.login__tag {
  color: var(--muted);
  font-size: 12.5px;
  margin: 16px 0 26px;
  letter-spacing: 0.01em;
}
.field { margin-bottom: 15px; }
.field label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin-bottom: 7px;
  font-weight: 600;
}
.field input, .field select {
  width: 100%;
  background: var(--ink-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 13px;
  font-size: 14px;
  font-family: var(--font-body);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px var(--brass-soft);
}

/* ---------- Controles de formulario: tema global (inputs sueltos, tablas) ---------- */
input:not([type=checkbox]):not([type=radio]):not([type=range]),
select, textarea {
  background: var(--ink-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13.5px;
  padding: 8px 11px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-soft);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238397a6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
}
.field select, .filters select { padding-right: 30px; }
option { background: var(--ink-deep); color: var(--text); }
input[type=checkbox], input[type=radio] { accent-color: var(--brass); width: 15px; height: 15px; cursor: pointer; }
/* Ocultar los spinners de number: compacta la columna Tarifa y similares. */
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
/* Inputs/selects dentro de tablas: compactos y sin forzar ancho mínimo. */
table input, table select { padding: 5px 8px; font-size: 12.5px; min-width: 0; }
table select { padding-right: 24px; background-position: right 6px center; }
.btn {
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  background: var(--brass);
  color: #1a1204;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: var(--brass-bright); }
.btn:active { transform: translateY(1px); }
.btn--ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.login__hint {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--muted-2);
  line-height: 1.7;
}
.login__hint code { font-family: var(--font-mono); color: var(--brass); }
.login__error {
  background: rgba(229, 96, 77, 0.12);
  border: 1px solid rgba(229, 96, 77, 0.4);
  color: #f0a599;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 12.5px;
  margin-bottom: 16px;
}

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100%; }
.sidebar {
  background: var(--ink-deep);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand { padding: 4px 8px 22px; flex: 0 0 auto; }
/* La nav ocupa el espacio restante y hace scroll interno cuando hay muchos items
   (min-height:0 es imprescindible para que un flex-item pueda encoger y desbordar). */
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
/* adminceo · interruptor de vistas técnicas */
.nav__tech {
  display: flex; align-items: center; gap: 11px;
  margin: 10px 2px 2px; padding: 9px 11px;
  background: transparent; border: 1px dashed var(--line); border-radius: var(--radius-sm);
  color: var(--muted-2); font-size: 12.5px; font-weight: 500; cursor: pointer; text-align: left;
}
.nav__tech:hover { color: var(--text); border-color: var(--brass); }
.nav__tech.is-on { color: var(--brass-bright); border-style: solid; border-color: rgba(200,155,60,0.28); background: var(--brass-soft); }
.nav__tech svg { width: 16px; height: 16px; flex: none; }
.nav__label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted-2);
  padding: 16px 10px 8px;
  font-weight: 600;
}
.nav__item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.12s, color 0.12s;
}
.nav__item:hover { background: var(--surface); color: var(--text); }
.nav__item.is-active {
  background: var(--brass-soft);
  color: var(--brass-bright);
  border-color: rgba(200, 155, 60, 0.28);
}
.nav__item svg { width: 17px; height: 17px; flex: none; }
.sidebar__spacer { flex: 0 0 auto; }
.userchip { flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 8px;
  border-top: 1px solid var(--line-soft);
  margin-top: 8px;
}
.userchip__avatar {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--brass-bright);
  font-size: 14px;
}
.userchip__meta { line-height: 1.25; min-width: 0; }
.userchip__name { font-size: 13px; font-weight: 600; }
.userchip__role { font-size: 11px; color: var(--muted-2); }
.userchip__logout {
  margin-left: auto;
  background: none; border: none;
  color: var(--muted-2);
  padding: 6px;
  border-radius: 6px;
}
.userchip__logout:hover { color: var(--danger); background: var(--surface); }

/* ---------- Main ---------- */
.main { min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  /* El fondo sticky ocupa todo el ancho, pero el contenido (título + campana) se
     alinea a la misma columna centrada que el .view de abajo (máx. 1480px). */
  padding: 20px max(32px, calc((100% - 1480px) / 2 + 32px));
  border-bottom: 1px solid var(--line-soft);
  position: sticky; top: 0;
  background: rgba(15, 26, 36, 0.85);
  backdrop-filter: blur(8px);
  z-index: 5;
}
.topbar h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  letter-spacing: -0.02em;
  margin: 0;
}
.topbar__sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.view { padding: 28px 32px 60px; max-width: 1480px; margin-inline: auto; }

/* Scrollbars a juego con el tema (petróleo/latón) — WebKit + Firefox. */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 8px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--brass); }
::-webkit-scrollbar-corner { background: transparent; }

/* eyebrow */
.eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--brass); font-weight: 600; font-family: var(--font-mono);
}

/* ---------- Portal signal tiles (firma) ---------- */
.signals {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  margin: 14px 0 34px;
}
.signal {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  position: relative;
  overflow: hidden;
}
.signal__top { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.signal__name { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.pulse {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted-2);
  position: relative; flex: none;
}
.pulse--active { background: var(--signal); box-shadow: 0 0 0 0 rgba(63, 185, 138, 0.5); animation: pulse 2.4s infinite; }
.pulse--flaky { background: var(--warn); }
.pulse--blocked { background: var(--danger); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(63, 185, 138, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(63, 185, 138, 0); }
  100% { box-shadow: 0 0 0 0 rgba(63, 185, 138, 0); }
}
.signal__count { font-family: var(--font-mono); font-size: 27px; font-weight: 500; letter-spacing: -0.02em; }
.signal__meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.signal__state {
  margin-top: 12px; font-size: 11px; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.signal__state.active { color: var(--signal); }
.signal__state.flaky { color: var(--warn); }
.signal__state.blocked { color: var(--danger); }

/* ---------- Stat row ---------- */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 34px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat__k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.stat__v { font-family: var(--font-mono); font-size: 26px; margin-top: 6px; letter-spacing: -0.02em; }
.stat__v small { font-size: 13px; color: var(--muted); }

/* ---------- Filters ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
}
.filters .field { margin: 0; }
.filters .field label { margin-bottom: 5px; }
.filters select, .filters input {
  background: var(--ink-deep); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 8px 10px; font-size: 13px; font-family: var(--font-body);
  min-width: 0;
}
.filters select:focus, .filters input:focus { outline: none; border-color: var(--brass); }
.filters__spacer { flex: 1; }

/* ---------- Table ---------- */
.table-wrap { border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 11px 14px;
  background: var(--ink-deep);
  color: var(--muted); font-weight: 600;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s; cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
.cell-price { font-family: var(--font-mono); font-weight: 500; white-space: nowrap; }
.cell-mono { font-family: var(--font-mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.cell-title { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }

/* chips / badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 20px;
  border: 1px solid var(--line);
}
.badge--particular { color: var(--signal); border-color: rgba(63, 185, 138, 0.35); background: rgba(63, 185, 138, 0.1); }
.badge--agencia { color: var(--brass-bright); border-color: rgba(200, 155, 60, 0.3); background: var(--brass-soft); }
.badge--na { color: var(--muted-2); }
.tag-op { font-family: var(--font-mono); font-size: 11px; padding: 2px 7px; border-radius: 5px; border: 1px solid var(--line); color: var(--muted); }

/* pagination */
.pager { display: flex; align-items: center; gap: 12px; margin-top: 16px; justify-content: flex-end; font-size: 13px; color: var(--muted); }
.pager button {
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--radius-sm); padding: 7px 13px; font-size: 13px;
}
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }
.pager button:not(:disabled):hover { border-color: var(--brass); }

/* crawl runs */
.run { display: grid; grid-template-columns: 130px 90px 1fr auto; gap: 14px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.run:last-child { border-bottom: none; }
.run__portal { font-family: var(--font-display); font-weight: 700; }
.run__nums { font-family: var(--font-mono); color: var(--muted); font-size: 12px; }
.run__time { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted-2); }

/* detail drawer */
.drawer-back {
  position: fixed; inset: 0; background: rgba(6, 11, 16, 0.6);
  backdrop-filter: blur(2px); z-index: 2000; opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.drawer-back.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 440px; max-width: 92vw;
  background: var(--surface); border-left: 1px solid var(--line);
  z-index: 2001; transform: translateX(100%); transition: transform 0.24s ease;
  overflow-y: auto; padding: 26px 26px 40px;
}
.drawer.open { transform: translateX(0); }
.drawer__price { font-family: var(--font-mono); font-size: 30px; margin: 6px 0 2px; }
.drawer__row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.drawer__row span:first-child { color: var(--muted); }
.spark { display: flex; align-items: flex-end; gap: 4px; height: 60px; margin: 14px 0; }
.spark__bar { flex: 1; background: var(--brass-soft); border-top: 2px solid var(--brass); border-radius: 2px 2px 0 0; min-height: 4px; }

/* galería de la ficha */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 4px 0 16px; }
.gallery img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); cursor: zoom-in; transition: transform 0.12s; background: var(--ink-deep); }
.gallery img:hover { transform: scale(1.03); border-color: var(--brass); }
.phone-link { color: var(--brass-bright); font-family: var(--font-mono); font-weight: 500; }
.enrich-note { margin-top: 18px; padding: 12px 14px; background: var(--brass-soft); border: 1px solid rgba(200,155,60,0.3); border-radius: var(--radius-sm); font-size: 12px; color: var(--muted); }
.enrich-note code { font-family: var(--font-mono); color: var(--brass-bright); font-size: 11px; }

/* miniatura en tabla */
.cell-thumb { width: 52px; padding: 6px 8px 6px 14px !important; }
.cell-thumb img { width: 44px; height: 34px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); display: block; }
.thumb-empty { display: block; width: 44px; height: 34px; border-radius: 5px; background: var(--ink-deep); border: 1px solid var(--line-soft); }
.dot-phone { color: var(--signal); font-size: 11px; }

.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.section-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; margin: 0 0 4px; }
.section-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; }

/* Mini-dashboard: KPIs + charts de cabecera */
.stat__sub { color: var(--muted-2); font-size: 11px; margin-top: 3px; font-family: var(--font-mono); }
.charts-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin: 14px 0 22px; }
.chart-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0));
}
.chart-card__t {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 1.6px;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.chart-card svg { width: 100%; height: auto; display: block; }

/* Modal genérico */
.modal-back {
  position: fixed; inset: 0; background: rgba(4, 10, 15, 0.72); backdrop-filter: blur(4px);
  z-index: 3000; opacity: 0; pointer-events: none; transition: opacity 0.15s ease;
}
.modal-back.open { opacity: 1; pointer-events: auto; }
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -46%) scale(0.97);
  width: min(460px, calc(100vw - 32px)); max-height: 88vh; overflow-y: auto;
  background: linear-gradient(180deg, #14222f, #0f1a24);
  border: 1.5px solid var(--brass); border-radius: 16px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(200, 155, 60, 0.12), 0 0 46px rgba(200, 155, 60, 0.08);
  padding: 24px 26px;
  z-index: 3001; opacity: 0; pointer-events: none; transition: opacity 0.16s ease, transform 0.16s ease;
}
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal .modal__title { position: relative; padding-left: 2px; }
.modal .modal__title::before { content: ''; position: absolute; left: -26px; top: -24px; right: -26px; height: 3px;
  background: linear-gradient(90deg, var(--brass), var(--brass-bright), transparent); border-radius: 16px 16px 0 0; }
.modal__title { font-family: var(--font-display); font-weight: 700; font-size: 17px; margin: 0 0 16px; }

/* Pestañas (Ajustes) */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--line-soft); padding-bottom: 10px; }
.tabs__tab {
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  color: var(--muted); font-family: var(--font-mono); font-size: 11.5px;
  letter-spacing: 0.6px; padding: 7px 13px; cursor: pointer;
}
.tabs__tab:hover { color: var(--brass-bright); border-color: var(--brass); }
.tabs__tab.is-active { color: #0f1a24; background: var(--brass); border-color: var(--brass); font-weight: 700; }

/* Documentación interna (docs/*.md) */
/* minmax(0,1fr): permite que la columna de contenido ENCOJA bajo su contenido
   (si no, una tabla ancha estira la columna y se sale de ancho). */
.docs-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 22px; align-items: start; }
.docs-nav { position: sticky; top: 90px; min-width: 0; }
.docs-nav__toggle { display: none; }                 /* desktop: sin barra */
.docs-nav__inner { display: flex !important; flex-direction: column; gap: 2px; } /* desktop: siempre visible */
.docs-nav .nav__label { margin-top: 14px; }
.docs-nav .nav__label:first-child { margin-top: 0; }
.docs-nav__item {
  padding: 6px 10px; border-radius: 7px; font-size: 13px; color: var(--muted);
  text-decoration: none; line-height: 1.35;
}
.docs-nav__item:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.docs-nav__item.is-active { color: var(--brass-bright); background: var(--brass-soft); }
.doc-body {
  max-width: 74ch; min-width: 0; font-size: 14px; line-height: 1.7;
  border: 1px solid var(--line); border-radius: 12px; padding: 30px 36px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
  overflow-wrap: anywhere; /* URLs/palabras largas no desbordan */
}
.doc-body h1 { font-family: var(--font-display); font-size: 22px; margin: 0 0 14px; }
.doc-body h2 { font-family: var(--font-display); font-size: 16px; margin: 26px 0 8px; color: var(--brass-bright); }
.doc-body h3 { font-family: var(--font-display); font-size: 14px; margin: 18px 0 6px; }
.doc-body p { margin: 0 0 12px; }
.doc-body ul, .doc-body ol { margin: 0 0 12px; padding-left: 22px; }
.doc-body li { margin-bottom: 5px; }
.doc-body code { font-family: var(--font-mono); font-size: 12.5px; color: var(--brass-bright); background: rgba(255, 255, 255, 0.05); padding: 1px 5px; border-radius: 4px; }
.doc-body pre { background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line-soft); border-radius: 8px; padding: 12px 14px; overflow-x: auto; margin: 0 0 12px; }
.doc-body pre code { background: none; padding: 0; color: inherit; }
.doc-body blockquote { border-left: 3px solid var(--brass); margin: 0 0 12px; padding: 4px 14px; color: var(--muted); }
.doc-body hr { border: none; border-top: 1px solid var(--line-soft); margin: 20px 0; }
/* La tabla ocupa su ancho natural pero mínimo el 100%; si no cabe, scrollea dentro
   de .table-scroll (overflow-x:auto) en vez de desbordar la página. */
.doc-body .table-scroll { max-width: 100%; overflow-x: auto; margin: 0 0 14px; }
.doc-body table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 13px; }
.doc-body th, .doc-body td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line-soft); }
.doc-body th { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.doc-body a { color: var(--brass-bright); }

@media (max-width: 900px) {
  .docs-layout { grid-template-columns: 1fr; }
  /* Índice colapsable en móvil: una barra que despliega los capítulos. */
  .docs-nav { position: static; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--surface); margin-bottom: 14px; }
  .docs-nav__toggle { display: block; padding: 11px 14px; cursor: pointer; font-weight: 600; font-size: 13.5px; list-style: none; color: var(--text); }
  .docs-nav__toggle::-webkit-details-marker { display: none; }
  .docs-nav__toggle::after { content: '▸'; float: right; color: var(--muted-2); }
  .docs-nav[open] .docs-nav__toggle::after { content: '▾'; }
  .docs-nav__inner { display: none !important; padding: 4px 8px 10px; max-height: 55vh; overflow-y: auto; }
  .docs-nav[open] .docs-nav__inner { display: flex !important; }
  .doc-body { padding: 20px 16px; }
}

/* Botones rápidos de login por rol */
.quick-login { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.quick-login button {
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  color: var(--muted); font-family: var(--font-mono); font-size: 11.5px;
  padding: 8px 6px; cursor: pointer; letter-spacing: 0.5px;
}
.quick-login button:hover { border-color: var(--brass); color: var(--brass-bright); }

/* Campana de notificaciones (M6) */
.bell { margin-left: auto; position: relative; }
.bell__btn {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 8px;
  background: transparent; border: 1px solid var(--line);
  color: var(--muted); cursor: pointer; position: relative;
}
.bell__btn:hover { color: var(--brass-bright); border-color: var(--brass); }
.bell__badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--brass);
  color: #0f1a24; font-size: 10.5px; font-weight: 700;
  font-family: var(--font-mono); display: grid; place-items: center;
}
.bell__panel {
  position: absolute; right: 0; top: 46px; width: 340px; max-height: 420px;
  overflow-y: auto; z-index: 30;
  background: rgba(15, 26, 36, 0.98); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  padding: 8px;
}
.bell__item {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  border-bottom: 1px solid var(--line-soft);
}
.bell__item:last-child { border-bottom: none; }
.bell__item:hover { background: var(--brass-soft); }
.bell__item--unread .bell__title { color: var(--brass-bright); }
.bell__title { font-size: 13px; font-weight: 600; }
.bell__body { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.45; }
.bell__time { font-size: 11px; color: var(--muted-2); font-family: var(--font-mono); margin-top: 3px; }

/* Botón hamburguesa: oculto en escritorio, visible en móvil. */
.hamburger {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: none;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text);
}
.hamburger:hover { background: var(--surface-2); }
.nav-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
  z-index: 1290; opacity: 0; pointer-events: none; transition: opacity 0.25s;
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 268px; z-index: 1300;
    transform: translateX(-100%); transition: transform 0.25s ease;
    border-right: 1px solid var(--line);
  }
  .app.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow); }
  .app.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  .hamburger { display: inline-flex; }
  .topbar { padding: 12px 15px; gap: 12px; }
  .topbar h1 { font-size: 18px; }
  .topbar__sub { display: none; }
  .view { padding: 18px 14px 60px; }
  .filters { padding: 12px; }
  .drawer { width: 100%; max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ==================== UX transversal (framework + multi-device) ==================== */

/* UX4 · Foco de teclado visible (solo con teclado, no con ratón). Los inputs ya
   usan borde+box-shadow latón; el resto no tenía foco visible. */
a:focus-visible, button:focus-visible, .btn:focus-visible, .nav__item:focus-visible,
.hamburger:focus-visible, summary:focus-visible, [tabindex]:focus-visible, tbody tr:focus-visible {
  outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 6px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* UX6 · (retirado) La cabecera sticky de tabla chocaba con el wrapper de scroll
   horizontal (.table-scroll con overflow-x:auto pasa a ser el contenedor de
   referencia del sticky y empujaba la cabecera hacia abajo dejando una banda
   vacía). El thead queda en flujo normal, sin sticky. Se mantienen el resto de
   mejoras UX6 (objetivos táctiles). */

/* UX7 · Sin scroll horizontal del body + áreas seguras (notch/gestos). */
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
.topbar { padding-top: max(20px, env(safe-area-inset-top)); }

/* UX1 · Toasts (feedback transitorio, esquina inf-dcha). */
.toasts {
  position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 4000; display: flex; flex-direction: column; gap: 8px; max-width: min(360px, 92vw);
}
.toast {
  background: linear-gradient(180deg, #14222f, #0f1a24);
  border: 1px solid var(--line); border-left: 3px solid var(--brass); border-radius: 10px;
  padding: 11px 14px; font-size: 13px; line-height: 1.4; color: var(--text);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5); animation: toast-in 0.18s ease;
}
.toast--success { border-left-color: var(--signal); }
.toast--error { border-left-color: var(--danger); }
.toast--info { border-left-color: var(--brass); }
.toast.hide { opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* UX2 · Barra de progreso superior (ligada a api()). */
.progressbar {
  position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 4001;
  background: linear-gradient(90deg, var(--brass), var(--brass-bright));
  box-shadow: 0 0 8px rgba(224, 181, 81, 0.5); opacity: 0;
  transition: width 0.2s ease, opacity 0.3s ease; pointer-events: none;
}
.progressbar.active { opacity: 1; }

/* UX6/UX7 móvil · thead más arriba, objetivos táctiles ≥40px, áreas seguras. */
@media (max-width: 860px) {
  .btn, .btn--ghost { min-height: 40px; }
  table input[type="checkbox"], table input[type="radio"] { width: 18px; height: 18px; }
  .filters { gap: 8px; }
  .topbar { padding-top: max(12px, env(safe-area-inset-top)); }
  .sidebar { padding-left: max(16px, env(safe-area-inset-left)); padding-bottom: max(22px, env(safe-area-inset-bottom)); }
  .view { padding-bottom: max(60px, env(safe-area-inset-bottom)); }
}

/* ---------- Índice de Oportunidad de Mercado (mini-card en la ficha) ---------- */
.opp-card {
  display: flex; align-items: center; gap: 16px;
  margin: 4px 0 14px; padding: 12px 14px;
  border: 1px solid var(--line-soft); border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(0,0,0,.08));
}
.opp-gauge { flex: 0 0 auto; }
.opp-num { font-family: var(--font-display, inherit); font-weight: 800; font-size: 22px; }
.opp-lvl { fill: var(--muted); font-size: 8.5px; letter-spacing: .14em; text-transform: uppercase; }
.opp-meta { flex: 1; min-width: 0; }
.opp-title { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; }
.opp-bar { display: flex; align-items: center; gap: 8px; margin: 3px 0; font-size: 11px; }
.opp-bar > span { flex: 0 0 58px; color: var(--muted); }
.opp-bar > i { height: 6px; border-radius: 4px; min-width: 2px; opacity: .85; transition: width .4s ease; }
.opp-bar > b { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--ink, #e7eef5); font-weight: 600; }
.opp-foot { margin-top: 8px; font-size: 11px; color: var(--ink, #cdd8e2); }
.opp-pill {
  display: inline-block; min-width: 26px; padding: 2px 7px;
  border: 1px solid; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,.03);
}
@media (prefers-reduced-motion: reduce) { .opp-bar > i { transition: none; } }
