:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1b1d21;
  --muted: #6a7180;
  --line: #dfe3ea;
  --accent: #1f5fd1;
  --hot: #d8452a;
  --warm: #d98324;
  --good: #1f8a5f;
  --cold: #8891a2;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: .92em; background: #eceff4; padding: 1px 5px; border-radius: 4px; }

/* ---------------------------------------------------------------- chrome */

.top {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 17px; color: var(--ink); }
.search { margin-left: auto; }
.search input {
  width: 260px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 7px; font-size: 14px; background: #fbfcfd;
}

main { max-width: 2200px; margin: 0 auto; padding: 22px 24px 60px; }
footer { max-width: 1500px; margin: 0 auto; padding: 0 24px 40px; color: var(--muted); font-size: 13px; }

h1 { font-size: 23px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 26px 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 18px; }

.flashes { max-width: 1500px; margin: 14px auto -6px; padding: 0 24px; }
.flash { margin: 0 0 8px; padding: 9px 14px; border-radius: 8px; background: #e7f3ec; border: 1px solid #bfdfcd; }
.flash.error { background: #fdecea; border-color: #f2c0b8; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 16px;
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .n { font-size: 27px; font-weight: 700; line-height: 1.1; }
.kpi .t { color: var(--muted); font-size: 13px; margin-top: 2px; }
.kpi a { color: inherit; }
.grid2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.grid2 > div { min-width: 0; }
.grid-forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

/* ---------------------------------------------------------------- tables */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 9px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: #f7f9fc; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px;
  font-weight: 600; white-space: nowrap; background: #eceff4; color: var(--muted);
}
.badge.EXCEPCIONAL { background: #fde8e3; color: var(--hot); }
.badge.LLAMAR_HOY { background: #fdf0dd; color: var(--warm); }
.badge.CONFIRMAR_DATO { background: #e6f0fd; color: var(--accent); }
.badge.INVESTIGAR { background: #f0e8fb; color: #6b3fbf; }
.badge.REVISAR { background: #e7f3ec; color: var(--good); }
.badge.alta { background: #fde8e3; color: var(--hot); }
.badge.media { background: #fdf0dd; color: var(--warm); }
.badge.baja { background: #eceff4; color: var(--cold); }
.badge.PRIME { background: #efe6fb; color: #6b3fbf; }
.badge.INTERMEDIA { background: #e6f0fd; color: var(--accent); }
.badge.VALUE { background: #eceff4; color: var(--muted); }
.badge.ok { background: #e7f3ec; color: var(--good); }
.badge.warn { background: #fdf0dd; color: var(--warm); }
.badge.bad { background: #fde8e3; color: var(--hot); }

.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.mine { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- forms */

form.inline { display: inline; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
input[type=text], input[type=number], input[type=search], input[type=email], input[type=password], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px;
  font: inherit; font-size: 14px; background: #fbfcfd; color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 10px; }
.row > * { flex: 1 1 130px; }
.row > .fit { flex: 0 0 auto; }

button, .button {
  padding: 8px 14px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 7px; font: inherit; font-size: 14px; cursor: pointer;
}
/* The grey hover is only for plain buttons: a coloured .btn keeps its own colour and just gets brighter (see .btn:hover) */
button:not(.btn):hover, .button:not(.btn):hover { background: #eef1f6; text-decoration: none; }
.button:hover { text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #1a51b3; }
button.link { border: none; background: none; color: var(--accent); padding: 2px 4px; }
button.small, .button.small { padding: 4px 9px; font-size: 13px; }

.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.filters > div { flex: 0 0 auto; }
.filters input, .filters select { min-width: 120px; width: auto; }
.filters .wide input { min-width: 230px; }

/* ---------------------------------------------------------------- flat page */

.flat-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.flat-head .prices { text-align: right; }
.flat-head .price { font-size: 26px; font-weight: 700; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px; margin: 14px 0 0; }
.facts div span { display: block; color: var(--muted); font-size: 12px; }
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 190px 1fr 62px; gap: 10px; align-items: center; font-size: 13px; }
.bar { background: #eceff4; border-radius: 4px; height: 9px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar > i.open { background: repeating-linear-gradient(90deg, #c9d2e0 0 4px, transparent 4px 8px); }
ul.plain { margin: 0; padding-left: 18px; }
ul.plain li { margin-bottom: 4px; }
.value-range { display: flex; gap: 14px; align-items: baseline; font-variant-numeric: tabular-nums; }
.value-range b { font-size: 19px; }
.notes li { margin-bottom: 10px; }
.contact-box { background: #f0f5ff; border: 1px solid #cfe0fb; border-radius: var(--radius); padding: 14px 16px; }
.contact-box .tel { font-size: 24px; font-weight: 700; letter-spacing: .5px; }
dl.pairs { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 14px; }
dl.pairs dt { color: var(--muted); }
dl.pairs dd { margin: 0; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 16px; }

/* ---------------------------------------------------------------- negotiation ladder */

table.ladder td, table.ladder th { padding: 7px 10px; }
table.ladder tr.step-entrada { background: #f2f8f4; }
table.ladder tr.step-acuerdo { background: #fbf7ee; }
table.ladder tr.step-maximo { background: #fdf1ee; }
table.ladder tr.step-maximo td { font-weight: 600; }
td.under { color: var(--good); }
tr.band-on { background: #eef3fb; }
tr.band-on td { font-weight: 600; }

/* ---------------------------------------------------------------- confirm by phone */

.card.confirm { border-color: #b9cff5; background: #f7faff; }
.ask { display: grid; grid-template-columns: 1fr 240px; gap: 18px; align-items: center; padding: 12px 0; border-top: 1px solid #dbe6f8; }
.ask:first-of-type { border-top: none; }
.ask.decides .ask-q > b { color: var(--ink); }
.ask .effect { margin-top: 6px; }
.with-unit { display: flex; gap: 8px; align-items: center; }
.with-unit input { width: 90px; }
@media (max-width: 900px) { .ask { grid-template-columns: 1fr; } }

/* status picker inside a list row */
select.quick { width: auto; min-width: 118px; padding: 3px 6px; font-size: 12px; }
.missing { display: flex; gap: 4px; flex-wrap: wrap; }
.button.primary-soft { background: #e6f0fd; border-color: #b9cff5; color: var(--accent); font-weight: 600; }
.button.primary-soft:hover { background: #d6e6fb; }

/* ---------------------------------------------------------------- map */

.map { height: 640px; border: 1px solid var(--line); border-radius: var(--radius); }
.destino-icon { color: var(--hot); font-weight: 700; font-size: 17px; line-height: 18px; text-align: center; text-shadow: 0 0 3px #fff; }
.leaflet-popup-content { font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

/* ---------------------------------------------------------------- progress */

.bar.big { height: 16px; border-radius: 8px; }
.bar.big > i { transition: width .4s ease; background: linear-gradient(90deg, #1f5fd1, #3f86f0); }
#job-etapas td { vertical-align: middle; }
#job-etapas .bar { min-width: 120px; }

/* ---------------------------------------------------------------- action buttons */

.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 8px;
  border: 1px solid transparent; color: #fff; font-weight: 600; font-size: 14px;
  box-shadow: 0 1px 2px rgba(20, 25, 40, .18); transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn.btn-blue:hover, .btn.btn-teal:hover, .btn.btn-sync:hover, .btn.btn-analyze:hover, .btn.btn-stop:hover { color: #fff; }
.btn:active { transform: translateY(1px); }
.btn .ico { flex: none; }
.btn-sync    { background: linear-gradient(180deg, #24a06f, #1a7f58); border-color: #17694a; color: #fff; }   /* green: goes to Idealista */
.btn-analyze { background: linear-gradient(180deg, #7d4fd6, #6338b8); border-color: #532e9c; color: #fff; }   /* violet: only recalculates */
.btn-stop    { background: linear-gradient(180deg, #e2553a, #c63f27); border-color: #a8331f; color: #fff; }
a.btn, a.btn:hover { color: #fff; }

.load-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; font-size: 14px; color: var(--ink); }
.load-line .ico { color: var(--accent); }

/* ---------------------------------------------------------------- moving a flat between lists */

table tr { transition: opacity .3s, background .3s; }
table tr.leaving { opacity: 0; background: #e7f3ec; }
select.quick.busy { opacity: .5; }
.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: 380px; padding: 12px 16px; border-radius: 10px;
  background: #1b1d21; color: #fff; font-size: 14px; box-shadow: 0 10px 30px rgba(20, 25, 40, .3);
  opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; pointer-events: auto; }
.toast.error { background: #a8331f; }
.toast a { color: #9fc4ff; margin-left: 6px; font-weight: 600; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 13px; }
.chip:hover { background: #eef1f6; text-decoration: none; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip b { font-variant-numeric: tabular-nums; }
.iconlink { display: inline-flex; padding: 5px; border-radius: 6px; color: var(--muted); }
.iconlink:hover { background: #eef1f6; color: var(--accent); text-decoration: none; }

/* ---------------------------------------------------------------- floating hints, popup, id, bell */

.tip {
  position: fixed; z-index: 100; max-width: 280px; padding: 8px 11px; border-radius: 8px; background: #1b1d21; color: #fff;
  font-size: 12.5px; line-height: 1.4; font-weight: 400; text-transform: none; letter-spacing: 0; text-align: left;
  box-shadow: 0 6px 20px rgba(20, 25, 40, .35); opacity: 0; pointer-events: none; transition: opacity .12s;
}
.tip.show { opacity: 1; }
[data-tip] { cursor: help; }
a[data-tip], button[data-tip], select[data-tip] { cursor: pointer; }

.id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; color: var(--muted); user-select: all; white-space: nowrap; }
.tag-phone { color: var(--good); display: inline-flex; vertical-align: middle; margin-left: 4px; }
.bell {
  display: inline-flex; align-items: center; gap: 3px; margin-left: 4px; padding: 2px 7px 2px 5px; border-radius: 999px;
  background: #fdf0dd; color: var(--warm); font-weight: 700; font-size: 12px; vertical-align: middle;
}
.bell:hover { background: #fbe4c0; text-decoration: none; }
.bell .ico { width: 14px; height: 14px; }
button.iconlink { border: none; background: none; cursor: pointer; padding: 5px; }
button.iconlink.call { color: var(--good); }
button.iconlink.call:hover { background: #e7f3ec; color: #16694a; }

dialog.popup {
  width: min(760px, 94vw); max-height: 88vh; padding: 0; border: none; border-radius: 14px; background: var(--panel); color: var(--ink);
  box-shadow: 0 25px 70px rgba(20, 25, 40, .45); overflow: hidden;
}
dialog.popup::backdrop { background: rgba(20, 25, 40, .5); }
dialog.popup[open] { display: flex; flex-direction: column; }
#resumen-cuerpo { padding: 22px 26px 18px; overflow-y: auto; }
.popup-close { position: absolute; top: 10px; right: 12px; border: none; background: #eef1f6; border-radius: 50%; width: 30px; height: 30px; padding: 0; z-index: 2; }
.popup-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 4px; padding-right: 34px; }
.popup-head .price { font-size: 24px; font-weight: 700; text-align: right; }
#resumen-cuerpo section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
#resumen-cuerpo h3 { margin: 0 0 8px; font-size: 15px; }
.reason { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.popup-table td { padding: 6px 8px; }
.popup-table tr.step-entrada { background: #f2f8f4; }
.popup-table tr.step-acuerdo { background: #fbf7ee; }
.popup-table tr.step-maximo { background: #fdf1ee; }
.popup-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.popup-foot .button { display: inline-flex; align-items: center; gap: 6px; }

/* help page */
.help { display: grid; grid-template-columns: 220px 1fr; gap: 32px; align-items: start; }
.help nav { position: sticky; top: 76px; font-size: 14px; display: grid; gap: 4px; }
.help nav a { padding: 4px 8px; border-radius: 6px; color: var(--ink); }
.help nav a:hover { background: #eef1f6; text-decoration: none; }
.help h2 { margin-top: 34px; padding-top: 4px; border-top: 1px solid var(--line); }
.help h2:first-of-type { margin-top: 0; border-top: none; }
.help dl { margin: 0; }
.help dt { font-weight: 700; margin-top: 16px; scroll-margin-top: 80px; }
.help dd { margin: 3px 0 0; color: #2b2f36; }
.help .rule { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.steps { counter-reset: paso; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: paso; position: relative; padding: 4px 0 12px 42px; }
.steps li::before {
  content: counter(paso); position: absolute; left: 0; top: 2px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 14px;
}
@media (max-width: 900px) { .help { grid-template-columns: 1fr; } .help nav { position: static; } }

/* ---------------------------------------------------------------- colours, top bar and menu */

.c-blue   { --c: #1f5fd1; --soft: #e6f0fd; }
.c-orange { --c: #d98324; --soft: #fdf0dd; }
.c-red    { --c: #d8452a; --soft: #fde8e3; }
.c-green  { --c: #1f8a5f; --soft: #e7f3ec; }
.c-amber  { --c: #b7860b; --soft: #fbf1cf; }
.c-teal   { --c: #0e8a95; --soft: #dff3f5; }
.c-violet { --c: #6b3fbf; --soft: #efe6fb; }
.c-gray   { --c: #6a7180; --soft: #eceff4; }

.top { gap: 14px; padding: 9px 22px; box-shadow: 0 1px 0 var(--line), 0 4px 14px rgba(20, 25, 40, .04); }
.brand {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; letter-spacing: -.2px;
  padding: 4px 6px 4px 0; margin-right: 6px;
}
.brand:hover { text-decoration: none; }
.brand .logo {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #2a6fe0, #1747a8); color: #fff; box-shadow: 0 2px 6px rgba(31, 95, 209, .35);
}
.brand .logo .ico { width: 18px; height: 18px; }

.top nav { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.nav-item {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 9px; color: var(--ink);
  font-size: 14px; font-weight: 500; white-space: nowrap; box-shadow: inset 0 -2px 0 transparent; transition: background .12s;
}
.nav-item .ico { color: var(--c); width: 17px; height: 17px; flex: none; }
.nav-item:hover { background: var(--soft); text-decoration: none; }
.nav-item.on { background: var(--soft); color: var(--c); font-weight: 700; box-shadow: inset 0 -2px 0 var(--c); }
.nav-item .pill {
  min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--c); color: #fff; font-size: 11.5px;
  font-weight: 700; text-align: center; line-height: 1.5;
}
.nav-item .pill.urgent { background: var(--hot); }
.nav-sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }

/* the "+" menu */
.menu { position: relative; }
.menu > summary {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px 7px 9px; border-radius: 9px; cursor: pointer; list-style: none;
  font-size: 14px; font-weight: 600; color: var(--c); background: var(--soft); border: 1px dashed var(--c);
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary .ico { width: 18px; height: 18px; transition: transform .18s; }
.menu[open] > summary .ico { transform: rotate(45deg); }         /* the "+" turns into a close cross */
.menu > summary:hover { filter: brightness(.97); }
.menu > summary.on { border-style: solid; }
.menu-panel {
  position: absolute; top: 44px; left: 0; z-index: 40; width: 330px; padding: 8px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 50px rgba(20, 25, 40, .22);
}
.menu-panel h4 { margin: 8px 10px 4px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.menu-item {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--ink); font-size: 14px;
}
.menu-item:hover { background: var(--soft); text-decoration: none; }
.menu-item.on { background: var(--soft); font-weight: 700; }
.menu-item .chip-ico {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--soft); color: var(--c); flex: none;
}
.menu-item .chip-ico .ico { width: 16px; height: 16px; }
.menu-item small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.3; }

/* search and help, on the right */
.top .search { margin-left: auto; position: relative; }
.top .search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; pointer-events: none; }
.top .search input { width: 200px; padding: 8px 12px 8px 34px; border-radius: 999px; background: #f3f5f9; border: 1px solid transparent; }
.top .search input:focus { outline: none; background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 95, 209, .15); }
.help-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--soft); color: var(--c); border: 1px solid transparent; flex: none;
}
.help-btn:hover { background: var(--c); color: #fff; text-decoration: none; }
.help-btn .ico { width: 20px; height: 20px; }
.help-btn.on { background: var(--c); color: #fff; }

/* ---------------------------------------------------------------- more buttons, all with an icon */

.btn .ico, .button .ico { width: 16px; height: 16px; flex: none; }
.button { display: inline-flex; align-items: center; gap: 7px; }
.btn-blue { background: linear-gradient(180deg, #2f78ec, #1b57c4); border-color: #1748a3; color: #fff; }
.btn-teal { background: linear-gradient(180deg, #17a2ae, #0e8590); border-color: #0b6d76; color: #fff; }
.btn-soft { background: var(--panel); border-color: var(--line); color: var(--ink); box-shadow: none; }
.btn-soft .ico { color: var(--muted); }
.btn-soft:hover { background: #eef1f6; filter: none; }
a.btn-soft, a.btn-soft:hover { color: var(--ink); }
.filters .btn { padding: 8px 14px; }

/* the KPI cards of the panel */
.kpi { position: relative; overflow: hidden; padding-left: 60px; }
.kpi .kpi-ico {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; background: var(--soft); color: var(--c);
}
.kpi .kpi-ico .ico { width: 18px; height: 18px; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }

/* discard popup and the reason shown in lists and on the flat page */
dialog.popup-small { width: min(520px, 94vw); }
.popup-small .popup-body { padding: 22px 24px 18px; }
.popup-small h2 { margin: 0 0 4px; }
.reasons { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.reasons .chip { cursor: pointer; font: inherit; font-size: 13px; }
.reasons .chip:hover { background: #fde8e3; border-color: #f2c0b8; }
#descarte-motivo { min-height: 84px; }
.popup-small .popup-foot { justify-content: flex-end; }
.reason-cell { max-width: 260px; }
.reason-text { font-weight: 600; color: #a8331f; }
.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; border: 1px solid var(--line); }
.banner .ico { width: 20px; height: 20px; flex: none; }
.banner.discard { background: #fdecea; border-color: #f2c0b8; color: #7a2418; }
.banner.info { background: #fdf6e3; border-color: #efdca0; color: #6b5610; }
.banner form { margin-left: auto; }

/* ---------------------------------------------------------------- email, configuration */

button.iconlink.mail { color: var(--accent); }
button.iconlink.mail:hover { background: #e6f0fd; color: #1a51b3; }
.help-btn + .help-btn { margin-left: -6px; }
.subject { padding: 8px 10px; border-radius: 7px; background: #f3f5f9; font-size: 14px; font-weight: 600; user-select: all; }
.checks { display: grid; gap: 8px; margin: 4px 0 6px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink); margin: 0; cursor: pointer; }
.check input { width: auto; margin-top: 3px; }
.check small { display: block; color: var(--muted); font-size: 12.5px; }
dialog#correo { width: min(560px, 94vw); }
#correo-cuerpo { padding: 22px 26px 18px; }

.config { display: grid; gap: 18px; max-width: 1100px; }
.config .card { margin: 0; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.card-head .badge-ico { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--soft); color: var(--c); flex: none; }
.card-head .badge-ico .ico { width: 20px; height: 20px; }
.card-head h2 { margin: 0; font-size: 18px; }
.card-sub { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px 22px; }
.field label { color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.field .hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; line-height: 1.4; }
.field .hint code { font-size: 12px; }
.field.wide { grid-column: 1 / -1; }
.tick-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tick { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fbfcfd; cursor: pointer; font-size: 14px; color: var(--ink); margin: 0; font-weight: 500; }
.tick:has(input:checked) { background: var(--soft); border-color: var(--c); color: var(--c); font-weight: 700; }
.tick input { width: auto; margin: 0; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.actions-row .spacer { margin-left: auto; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; }
.status-pill.ok { background: #e7f3ec; color: var(--good); }
.status-pill.no { background: #fdf0dd; color: var(--warm); }
.steps-small { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.steps-small li { margin-bottom: 3px; }
.sim { margin-top: 18px; }
.sim h3 { font-size: 14px; margin: 0 0 8px; }
.sim table td, .sim table th { padding: 7px 10px; }
.equals { padding: 10px 12px; background: #f3f5f9; border-radius: 8px; font-size: 13px; color: var(--muted); word-break: break-all; }
.equals b { color: var(--ink); }


/* ---------------------------------------------------------------- sign-in, account, users */

.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 9px; border-radius: 999px; background: var(--soft); color: var(--c);
             font-weight: 700; font-size: 13px; flex: none; }
.user-chip:hover { background: var(--c); color: #fff; text-decoration: none; }
.user-chip.on { background: var(--c); color: #fff; }
.user-chip small { display: block; font-weight: 500; font-size: 11px; opacity: .85; line-height: 1.1; }
.user-chip .ico { width: 18px; height: 18px; }
.top form.inline { margin: 0; }

/* a user who can only look: everything that changes something goes away (the server refuses it anyway) */
body.solo-ver .edita, body.solo-ver .mail, body.solo-ver [onclick*="abreCorreo"],
body.solo-ver form[method="post"]:not(.siempre) { display: none !important; }

body.login { background: linear-gradient(160deg, #eaf0fb, #f6f8fc 55%, #eef7f2); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: min(400px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 30px 30px 24px; box-shadow: 0 12px 40px rgba(20, 25, 40, .10); }
.login-box .logo { width: 46px; height: 46px; border-radius: 13px; display: flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; margin: 0 auto 12px; }
.login-box .logo .ico { width: 26px; height: 26px; }
.login-box h1 { text-align: center; margin: 0 0 4px; font-size: 22px; }
.login-box .sub { text-align: center; margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.login-box label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 13px; }
.login-box .btn { width: 100%; justify-content: center; margin-top: 18px; padding: 10px; }
.login-box .flash { margin: 0 0 12px; }
.login-box .foot { margin: 16px 0 0; text-align: center; font-size: 12.5px; color: var(--muted); }

.users td, .users th { vertical-align: middle; }
.users select { width: auto; min-width: 130px; padding: 4px 8px; }
.users .inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.users input[type=password] { width: 150px; padding: 4px 8px; }
.role-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.role-pill.admin { background: #ede7fa; color: #5a34a8; }
.role-pill.editor { background: #e6f0fd; color: #1a51b3; }
.role-pill.viewer { background: #eef1f6; color: #4a5263; }
.new-user { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.new-user h3 { margin: 0 0 10px; font-size: 15px; }
.roles-help { margin: 10px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); display: grid; gap: 4px; }

.top .user-chip small { display: none; }
@media (min-width: 1650px) { .top .user-chip small { display: block; } }
button.help-btn { padding: 0; cursor: pointer; font: inherit; }
button.help-btn:hover { background: var(--c); color: #fff; }
/* the bar has more on it now (user, sign-out): the search gives way before anything wraps */
.top .search { flex: 1 1 130px; min-width: 130px; max-width: 230px; }
.top .search input { width: 100%; }
@media (min-width: 1650px) { .top .search input { width: 100%; } }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: none; }
.top-right .search { margin-left: 0; flex: none; width: 210px; }
.top-right .help-btn + .help-btn { margin-left: 0; }

/* LuckyRadar's icon */
.brand .logo { background: none; width: 34px; height: 34px; border-radius: 9px; object-fit: cover; display: block; box-shadow: 0 1px 4px rgba(10, 30, 80, .35); }
.brand { display: inline-flex; align-items: center; gap: 9px; }
.login-box img.logo { width: 88px; height: 88px; border-radius: 22px; display: block; margin: 0 auto 12px; background: none; box-shadow: 0 6px 20px rgba(10, 30, 80, .28); }
.login-box .tagline { text-align: center; margin: 0 0 6px; color: var(--accent); font-weight: 600; font-size: 14px; }
footer b { color: var(--ink); }

/* The main photo of the ad. It is loaded from Idealista's CDN, so it can disappear when the ad is withdrawn:
   `sin-foto` hides the frame instead of leaving a broken image. */
.foto { display: block; flex: none; width: 200px; border-radius: 10px; overflow: hidden; background: #eef1f6; position: relative; line-height: 0; }
.foto:hover { text-decoration: none; }
.foto img { width: 100%; height: 150px; object-fit: cover; display: block; }
.foto .foto-pie {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 5px 8px; font-size: 11.5px; line-height: 1.3;
  color: #fff; background: linear-gradient(transparent, rgba(12, 18, 32, .82)); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.foto.sin-foto { display: none; }
.foto-mini { width: 132px; }
.foto-mini img { height: 99px; }
.flat-head .foto { margin-right: 18px; }
.popup-head .foto { margin-right: 16px; }
@media (max-width: 900px) { .foto { width: 140px; } .foto img { height: 105px; } }
.flat-head .foto + div, .popup-head .foto + div { flex: 1 1 260px; min-width: 0; }

/* Thumbnail in the tables, between the id and the zone */
.thumb-cell { width: 68px; padding-top: 6px; padding-bottom: 6px; }
.thumb { display: block; width: 64px; height: 48px; border-radius: 6px; overflow: hidden; background: #eef1f6; line-height: 0; }
.thumb img { width: 64px; height: 48px; object-fit: cover; display: block; }
.thumb:hover { outline: 2px solid var(--accent); outline-offset: 1px; text-decoration: none; }
.thumb.sin-foto { display: none; }


/* ---------------------------------------------------------------- several searches */

.switcher summary { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; background: var(--soft);
                    color: var(--c); font-weight: 700; font-size: 13.5px; cursor: pointer; list-style: none; max-width: 220px; }
.switcher summary::-webkit-details-marker { display: none; }
.switcher summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher summary .ico { width: 16px; height: 16px; flex: none; }
.switcher[open] summary, .switcher summary:hover { background: var(--c); color: #fff; }

.search-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; margin-top: 8px; }
.search-card { margin: 0; border-top: 4px solid var(--c); display: flex; flex-direction: column; }
.search-main { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.search-main:hover { text-decoration: none; }
.search-main:hover .search-name { color: var(--c); }
.search-main .badge-ico { width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
                          background: var(--soft); color: var(--c); flex: none; }
.search-main .badge-ico .ico { width: 22px; height: 22px; }
.search-main > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.search-name { font-size: 18px; }
.search-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.search-stats a { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border-radius: 9px; background: #f5f7fa;
                  color: var(--ink); }
.search-stats a:hover { background: var(--soft); text-decoration: none; }
.search-stats b { font-size: 20px; line-height: 1.1; }
.search-stats span { font-size: 11.5px; color: var(--muted); }
.search-stats a.hot b { color: #c0392b; }
.search-empty { margin: 14px 0 0; padding: 12px; border-radius: 9px; background: #f5f7fa; }
.search-card .actions-row { margin-top: auto; }
.search-manage { flex: 1 1 100%; }
.search-manage summary { cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.search-manage form { margin: 10px 0 0; }
.search-manage .row { display: flex; gap: 8px; align-items: flex-end; }
.search-manage .row > div:first-child { flex: 1; }
.global-tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: #ede7fa; color: #5a34a8;
              font-size: 10.5px; font-weight: 700; vertical-align: middle; }

.banner.gone { background: #f3f4f7; border-color: #d9dde5; color: #3b4150; }

/* ================================================================ phones and tablets
   One page for every screen. On a computer nothing below changes anything; from 900 px down the bar folds into a
   menu (☰), and from 720 px down the lists of flats become one card per flat. */

.menu-toggle, .hamburger, .nav-search { display: none; }

/* no mouse: no floating hints (a tap would leave them stuck on screen). Everything they say is also in Ayuda. */
@media (hover: none) {
  .tip { display: none !important; }
  [data-tip] { cursor: auto; }
  tbody tr:hover { background: inherit; }
}

/* the notch and the rounded corners of phones, when the app is opened from the home screen */
.top { padding-left: max(22px, env(safe-area-inset-left)); padding-right: max(22px, env(safe-area-inset-right)); }
.toast { bottom: max(22px, env(safe-area-inset-bottom)); }

/* ---------------------------------------------------------------- tablet (and phone) */
@media (max-width: 900px) {
  .top { gap: 10px; padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: 8px;
         padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .top > .brand { order: 1; margin-right: 0; }
  .top > .switcher { order: 2; min-width: 0; }
  .top > .top-right { order: 3; gap: 6px; }
  .top > .hamburger { order: 4; }
  .top > nav { order: 5; }
  .top-right .search { display: none; }          /* it moves into the menu */
  .top .user-chip > span { display: none; }       /* just the icon: the name is in «Tu cuenta» */
  .top .user-chip { padding: 8px; }

  .hamburger {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 4px; width: 42px; height: 42px; padding: 0 10px;
    border-radius: 10px; background: #f3f5f9; cursor: pointer; margin: 0; flex: none;
  }
  .hamburger span { display: block; height: 2px; border-radius: 2px; background: var(--ink); transition: transform .2s, opacity .2s; }
  .menu-toggle:checked + .hamburger { background: var(--accent); }
  .menu-toggle:checked + .hamburger span { background: #fff; }
  .menu-toggle:checked + .hamburger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .menu-toggle:checked + .hamburger span:nth-child(2) { opacity: 0; }
  .menu-toggle:checked + .hamburger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  /* the menu: every section, one under the other, under the bar */
  .top > nav { display: none; flex: 1 1 100%; flex-direction: column; align-items: stretch; gap: 2px;
               max-height: calc(100vh - 70px); max-height: calc(100dvh - 70px); overflow-y: auto; padding: 6px 0 10px;
               border-top: 1px solid var(--line); }
  .menu-toggle:checked ~ nav { display: flex; }
  .top nav .nav-item { padding: 11px 12px; font-size: 15.5px; }
  .top nav .nav-item .pill { margin-left: auto; }
  .top nav .nav-sep { width: auto; height: 1px; margin: 4px 0; }
  .nav-search { display: block; margin: 4px 0 8px; max-width: none; flex: none; }
  .top .nav-search input { width: 100%; padding-top: 10px; padding-bottom: 10px; }

  /* «Más» opens inside the menu instead of floating */
  .top nav .menu > summary { width: 100%; padding: 11px 12px; font-size: 15.5px; }
  .top nav .menu-panel { position: static; width: auto; box-shadow: none; border: none; padding: 4px 0 0; }
  .menu-item { padding: 10px; }

  /* the searches switcher: its list uses the whole width of the screen */
  .switcher summary { max-width: 42vw; }
  .switcher .menu-panel { position: fixed; top: 62px; left: 10px; right: 10px; width: auto; max-height: 75vh; overflow-y: auto; }

  main { padding: 16px 14px 48px; padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  footer { padding: 0 14px max(30px, env(safe-area-inset-bottom)); }
  .flashes { padding: 0 14px; }

  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .grid-forms { grid-template-columns: minmax(0, 1fr); }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .map { height: 70vh; min-height: 380px; }
  .bar-row { grid-template-columns: 130px 1fr 52px; }

  /* the popups take the whole screen */
  dialog.popup, dialog.popup-small, dialog#correo {
    width: 100vw; max-width: 100vw; height: 100%; max-height: 100%; margin: 0; border-radius: 0;
  }
  dialog.popup[open] { display: flex; }
  #resumen-cuerpo, #correo-cuerpo, .popup-small .popup-body {
    padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom)); overflow-y: auto; flex: 1;
  }
  .popup-close { top: max(10px, env(safe-area-inset-top)); width: 38px; height: 38px; font-size: 16px; }
  dialog#descarte .popup-small .popup-body, dialog#descarte .popup-body { display: flex; flex-direction: column; }
  dialog#descarte .popup-foot { margin-top: auto; }

  /* bigger targets for fingers */
  .iconlink, button.iconlink { padding: 9px; }
  .iconlink .ico { width: 20px; height: 20px; }
  select.quick { padding: 7px 8px; font-size: 14px; }
  .chip { padding: 7px 13px; }
}

/* ---------------------------------------------------------------- phone */
@media (max-width: 720px) {
  body { font-size: 15px; }
  h1 { font-size: 21px; }
  .brand { font-size: 0; gap: 0; }                /* only the icon: the bar is too narrow for the name */
  .brand .logo { width: 36px; height: 36px; }

  /* iOS zooms the page into any field with text smaller than 16 px */
  input[type=text], input[type=number], input[type=search], input[type=email], input[type=password], select, textarea,
  .top .search input, select.quick { font-size: 16px; }

  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 12px 12px 52px; }
  .kpi .kpi-ico { left: 10px; width: 32px; height: 32px; }
  .kpi .n { font-size: 23px; }
  .kpi .t { font-size: 12.5px; }
  .card { padding: 14px; overflow-x: auto; }
  .search-grid { grid-template-columns: minmax(0, 1fr); }
  .search-stats { grid-template-columns: repeat(2, 1fr); }

  /* filters: one per line, two where they fit, and the buttons full width */
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .filters > div, .filters > .wide { min-width: 0; }
  .filters > .wide { grid-column: 1 / -1; }
  .filters input, .filters select, .filters .wide input { min-width: 0; width: 100%; }
  .filters .btn, .filters .button { width: 100%; justify-content: center; }
  .row > * { flex-basis: 100%; }
  .actions { width: 100%; }
  .actions > .btn, .actions > .button, .actions > form { flex: 1 1 auto; justify-content: center; }
  .actions > form .btn { width: 100%; justify-content: center; }
  .actions-row .spacer { margin-left: 0; }

  /* the flat page and its popup: the photo on top, as wide as the screen */
  .flat-head { flex-direction: column; gap: 12px; }
  .flat-head .prices, .popup-head .price { text-align: left; }
  .flat-head .foto, .popup-head .foto { width: 100%; margin-right: 0; }
  .flat-head .foto img, .popup-head .foto img { height: auto; aspect-ratio: 4 / 3; }
  .popup-head { flex-direction: column; gap: 10px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .value-range { flex-wrap: wrap; gap: 6px 14px; }
  .bar-row { grid-template-columns: 1fr 52px; }
  .bar-row > :nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .banner { flex-wrap: wrap; }
  .banner form { margin-left: 0; }
  .ask { gap: 10px; }
  .help nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .toast { left: 12px; right: 12px; max-width: none; }



  /* the rest of the tables scroll sideways inside their box instead of widening the page */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table.ladder td, table.ladder th, .popup-table td { padding: 6px; }
}

/* ---------------------------------------------------------------- very narrow phones */
@media (max-width: 380px) {
  .cards { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: minmax(0, 1fr); }
  .switcher summary { max-width: 36vw; }
}

/* ---------------------------------------------------------------- second pass: menu search, card lines, folding filters */
.filtros-boton { display: none; }
@media (max-width: 900px) {
  .top nav .nav-search { flex: none; width: 100%; max-width: none; min-width: 0; margin: 4px 0 8px; position: relative; }
}
@media (max-width: 720px) {
  .top-right .help-btn.c-gray { display: none; }     /* Configuración: it is in «Más» */
  .filtros-boton { display: inline-flex; width: 100%; justify-content: center; margin: 0 0 12px; }
  .filtros-boton .pill-n { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; }
  .filtros-toggle:checked + .filtros-boton { background: #eef1f6; }
  .filtros-toggle:not(:checked) ~ .filters.plegable { display: none; }
  .filters > .filters { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  /* stacked, the header's parts must not stretch to the width they had side by side */
  .flat-head > *, .flat-head .foto + div, .popup-head .foto + div, .popup-head > * { flex: none; width: 100%; }
}
@media (max-width: 720px) { .flat-head { margin-bottom: 14px; } }

/* ---------------------------------------------------------------- the lists as cards (tablet in portrait and phone)
   One card per flat: photo, zone and score on top; id and badges; the figures, each with its name; what is missing;
   and at the bottom your state and the buttons. */
@media (max-width: 900px) {
  table.fichas, table.fichas tbody { display: block; }
  table.fichas thead { display: none; }
  .table-wrap:has(table.fichas) { background: none; border: none; overflow: visible; }
  table.fichas tr {
    display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 12px; padding: 12px; margin-bottom: 10px;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  }
  /* an empty item that fills a whole line: the figures always start below the id and the badges */
  table.fichas tr::before { content: ""; order: 5; flex: 0 0 100%; height: 0; margin-top: -10px; }
  table.fichas tr.vacia { display: block; }
  table.fichas tr.vacia::before { display: none; }
  table.fichas tr.muted { opacity: .75; }
  table.fichas td { display: block; padding: 0; border: none; text-align: left; white-space: normal; }
  table.fichas td:empty { display: none; }

  table.fichas .col-foto { order: 1; width: auto; padding: 0; }
  table.fichas .col-foto:not(:has(.thumb)) { display: none; }
  table.fichas .col-foto .thumb, table.fichas .col-foto .thumb img { width: 92px; height: 69px; border-radius: 8px; }
  table.fichas .col-zona { order: 2; flex: 1 1 calc(100% - 180px); min-width: 0; font-size: 15.5px; }
  table.fichas .col-zona .small { overflow-wrap: anywhere; }
  table.fichas .col-score, table.fichas .col-titulo { order: 3; }
  table.fichas .col-score { flex: none; text-align: right; font-size: 24px; line-height: 1.1; }
  table.fichas .col-badge, table.fichas .col-id { order: 4; flex: none; }
  table.fichas .col-id { align-self: center; font-size: 11.5px; }
  table.fichas .col-dato { order: 6; flex: 1 1 calc(33.33% - 12px); min-width: 88px; font-size: 14px; }
  table.fichas .col-dato .small, table.fichas .col-dato .muted { font-size: 12px; }
  table.fichas .col-extra { flex-basis: calc(50% - 12px); }
  table.fichas .col-ancha { order: 7; flex: 1 1 100%; max-width: none; }
  table.fichas .col-score::before, table.fichas .col-dato::before, table.fichas .col-ancha[data-label]::before {
    content: attr(data-label); display: block; font-size: 10.5px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .04em; color: var(--muted); margin-bottom: 1px;
  }
  table.fichas .col-estado { order: 8; flex: 1 1 150px; display: flex; align-items: center; gap: 6px;
                             padding: 10px 12px 0 0; margin-right: -12px; border-top: 1px solid var(--line); }
  table.fichas .col-estado form { flex: 1; }
  table.fichas .col-estado select.quick { width: 100%; }
  table.fichas .col-botones { order: 9; flex: 0 0 auto; display: flex; justify-content: flex-end; gap: 2px; padding-top: 10px;
                              border-top: 1px solid var(--line); }
  table.fichas .col-botones .link { padding: 8px 10px; font-size: 14px; }
  table.fichas .col-botones { flex-grow: 1; }
  table.fichas .col-titulo.col-ancha { order: 5; font-size: 15px; }     /* an alert: what happened, right under its badges */
}
/* a tablet has room for two cards side by side */
@media (min-width: 721px) and (max-width: 900px) {
  table.fichas tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  table.fichas tr { margin: 0; }
  table.fichas tr.vacia { grid-column: 1 / -1; }
}
@media (max-width: 380px) { table.fichas .col-dato { flex-basis: calc(50% - 12px); } }

/* ---------------------------------------------------------------- demand meter (market.demand): not part of the score */
.badge.demanda-alta { background: #fde8e3; color: var(--hot); }
.badge.demanda-baja { background: #e6f0fd; color: var(--accent); }
.demanda-box { border-radius: 9px; padding: 10px 12px; background: #f5f7fa; border-left: 4px solid var(--cold); }
.demanda-box.demanda-alta { background: #fdf3f0; border-left-color: var(--hot); }
.demanda-box.demanda-baja { background: #f0f5ff; border-left-color: var(--accent); }
.demanda-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.demanda-n { font-weight: 700; font-variant-numeric: tabular-nums; }
.badge.provisional { background: transparent; border: 1px dashed currentColor; opacity: .75; }

/* ---------------------------------------------------------------- the negotiation at a glance (_negociacion.html) */
.neg-boxes, .valor-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.neg-box, .valor-box { border-radius: 10px; padding: 10px 12px; background: #f5f7fa; border-top: 4px solid var(--cold); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.neg-box .k, .valor-box .k { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.neg-box b, .valor-box b { font-size: 20px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.neg-box .small, .valor-box .small { color: var(--muted); }
.box-entrada { background: #eef7f1; border-top-color: var(--good); }
.box-acuerdo { background: #fdf6ea; border-top-color: var(--warm); }
.box-maximo { background: #fdf0ed; border-top-color: var(--hot); }
.valor-real { background: #eef3fd; border-top-color: var(--accent); }
.valor-real b { color: var(--accent); }

.neg-bar { margin: 16px 0 6px; padding: 0 6px; }
.neg-track { position: relative; height: 12px; border-radius: 6px; background: #e8ecf2; margin: 48px 0 30px; }
.neg-seg { position: absolute; top: 0; bottom: 0; border-radius: 6px; }
.seg-entrada { background: #7cc79f; }
.seg-acuerdo { background: #f0b45f; }
.neg-mark { position: absolute; top: -6px; bottom: -6px; width: 0; }
.neg-mark i { position: absolute; left: -1.5px; top: 0; bottom: 0; width: 3px; border-radius: 2px; background: var(--ink); }
.neg-mark em { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; font-style: normal; font-size: 11.5px; color: var(--muted); }
.neg-mark em b { color: var(--ink); font-variant-numeric: tabular-nums; }
.mark-maximo i { background: var(--hot); }
.mark-maximo em { top: 28px; }
.mark-pedido em, .mark-zona em { bottom: 28px; }
.mark-zona i { background: var(--accent); }
.mark-zona em { color: var(--accent); }
.mark-zona em { bottom: 46px; }
.neg-mark.edge-l em { transform: none; left: -2px; }
.neg-mark.edge-r em { transform: translateX(-100%); left: 2px; }
.neg-legend { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.neg-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 8px; }
.neg-legend .dot.seg-entrada { background: #7cc79f; } .neg-legend .dot.seg-acuerdo { background: #f0b45f; }

.neg-why { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.why-col { border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.why-col ul { margin: 4px 0 0; padding-left: 18px; }
.why-col li { margin-bottom: 3px; }
.why-good { background: #eef7f1; } .why-good b { color: var(--good); }
.why-bad { background: #fdf0ed; } .why-bad b { color: var(--hot); }
.neg-source { margin: 10px 0 0; }
.neg-detalle { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.neg-detalle > summary { cursor: pointer; color: var(--accent); }

@media (max-width: 720px) {
  .neg-boxes, .valor-grid { grid-template-columns: minmax(0, 1fr); }
  .neg-box, .valor-box { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
  .neg-box .k, .valor-box .k { flex: 1 1 100%; }
  .neg-why { grid-template-columns: minmax(0, 1fr); }
  .neg-mark em { font-size: 10.5px; }
}

/* ---------------------------------------------------------------- the global filters (one set for every list, the panel and the map) */
.filtros-globales { max-width: 2200px; margin: 14px auto 0; padding: 0 24px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filtros-globales > details { flex: 0 0 auto; }
.filtros-globales > details[open] { flex: 1 1 100%; order: 10; }
.filtros-globales > details > summary { list-style: none; cursor: pointer; }
.filtros-globales > details > summary::-webkit-details-marker { display: none; }
.filtros-globales > details[open] > summary { margin-bottom: 10px; }
.filtros-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 0; }
.filtros-form .checks-inline { display: flex; gap: 14px; align-items: center; align-self: center; }
.filtros-form .check { margin: 0; }
.filtro-chip { cursor: pointer; font: inherit; font-size: 13px; }
.filtro-chip:hover { background: #1a51b3; }
#cerca-form button.busy { opacity: .5; }
.cerca-dato { color: #1f5fd1; font-weight: 600; white-space: nowrap; }
.cerca-dato svg { width: 12px; height: 12px; vertical-align: -1px; }
.pill-n { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; }
@media (max-width: 900px) { .filtros-globales { padding: 0 14px; } }
@media (max-width: 720px) {
  .filtros-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filtros-form .checks-inline, .filtros-form .fit { grid-column: 1 / -1; }
  .filtros-form .btn { width: 100%; justify-content: center; }
}
.filtros-form .check input { min-width: 0; width: auto; margin: 0; }
.filtros-form .check { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }

/* ---------------------------------------------------------------- the contact tray (contactar.html) */
.contactos { display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 14px; }
.contacto { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.contacto-head { display: flex; gap: 12px; align-items: flex-start; }
.contacto-que { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.contacto-estado { text-align: right; color: var(--muted); flex: none; max-width: 40%; }
.contacto textarea.mensaje { min-height: 150px; font-size: 14px; line-height: 1.45; }
.contacto .actions .spacer { flex: 1; }
.mensaje-enviado { white-space: pre-wrap; font: inherit; background: #f5f7fa; padding: 10px; border-radius: 8px; margin: 6px 0 0; }
.firma { max-width: 760px; }
@media (max-width: 720px) {
  .contactos { grid-template-columns: minmax(0, 1fr); }
  .contacto-head { flex-wrap: wrap; }
  .contacto-estado { text-align: left; max-width: none; flex: 1 1 100%; }
  .contacto .actions .btn { flex: 1 1 100%; justify-content: center; }
}

/* ---------------------------------------------------------------- not selling (market.sale_verdict): a meter for the negotiation */
.badge.venta-no { background: #efe7fd; color: #6b3fc4; }
.badge.venta-cuesta { background: transparent; color: #6b3fc4; border: 1px dashed #b49ae8; }
.venta-resumen { color: #6b3fc4; margin-top: 2px; line-height: 1.3; }
.bajadas-n { color: #6b3fc4; font-weight: 600; }
.venta-box { border-radius: 9px; padding: 10px 12px; background: #f6f2fe; border-left: 4px solid #8a63d8; }
.venta-box.venta-cuesta { background: #faf8fe; border-left-color: #b49ae8; }
.venta-fuerte { color: #6b3fc4; }
.venta-aviso { display: flex; gap: 10px; align-items: flex-start; background: #f6f2fe; border: 1px solid #e1d6fa; border-radius: var(--radius);
               padding: 10px 14px; margin: 0 0 14px; font-size: 14px; }
.venta-aviso > .ico { color: #6b3fc4; flex: none; margin-top: 3px; }
.venta-links { margin-top: 4px; font-size: 13.5px; }
.timeline { list-style: none; margin: 12px 0 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); }
.timeline li { position: relative; margin: 0 0 7px; }
.timeline li::before { content: ""; position: absolute; left: -21px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--cold); }
.timeline li.ev-bajada::before { background: #6b3fc4; }
.timeline li.ev-subida::before, .timeline li.ev-sale::before { background: var(--warm); }
.timeline li.ev-vuelve::before, .timeline li.ev-republicado::before { background: var(--accent); }
.ev-fecha { color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
.ev-baja { color: #6b3fc4; }

/* ---------------------------------------------------------------- the market page (estadisticas.py) */
.mercado-elige { margin-bottom: 14px; }
.termo-card { border-left: 6px solid var(--accent); }
.termo-card.termo-vendedor { border-left-color: var(--hot); }
.termo-card.termo-comprador { border-left-color: var(--good); }
.termo-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.termo-nombre { font-size: 22px; font-weight: 700; color: var(--accent); }
.termo-vendedor .termo-nombre, .termo.termo-vendedor b { color: var(--hot); }
.termo-comprador .termo-nombre, .termo.termo-comprador b { color: var(--good); }
.termo { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 17px; }
.termo.termo-equilibrado b { color: var(--accent); }
ul.senales { list-style: none; padding-left: 0; }
.senales li { margin-bottom: 5px; padding-left: 1.5em; text-indent: -1.5em; }
.voto { display: inline-block; width: 1.3em; text-align: center; font-weight: 700; }
.voto-comprador { color: var(--good); }
.voto-vendedor { color: var(--hot); }
.voto-neutro { color: var(--cold); }
.consejos ul { margin: 6px 0 0; padding-left: 20px; }
.consejos li { margin-bottom: 6px; }
.graficos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 14px 0 20px; }
.grafico { margin: 0; color: var(--accent); min-width: 0; }
.grafico-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; color: var(--ink); }
.grafico-head .k { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); flex: 1 1 100%; }
.grafico-head b { font-size: 20px; font-variant-numeric: tabular-nums; }
.grafico svg { display: block; margin-top: 6px; overflow: visible; }
.grafico circle { fill: var(--panel); stroke: currentColor; stroke-width: 2; }
.grafico-pie { display: flex; justify-content: space-between; gap: 6px; }
.grafico .under, .zonas-tabla .under { color: var(--good); }
.grafico .sube, .zonas-tabla .sube { color: var(--hot); }
.badge.margen-mas { background: #e7f3ec; color: var(--good); }
.badge.margen-menos { background: #fde8e3; color: var(--hot); }
.badge.margen-normal { background: #eef1f6; color: var(--muted); }
details.zonas > summary { cursor: pointer; margin: 6px 0 10px; }
@media (max-width: 900px) { .graficos { grid-template-columns: minmax(0, 1fr); } }
.bajadas-titulo { margin: 14px 0 6px; font-size: 14px; }
.bajadas-tabla { width: 100%; border-collapse: collapse; }
.bajadas-tabla th, .bajadas-tabla td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.bajadas-tabla tfoot td { border-bottom: 0; border-top: 2px solid var(--line); }
.bajadas-tabla .under { color: var(--good); }
.bajadas-tabla .sube { color: var(--hot); }
.bajadas-tabla tr.paso-subida td { background: #fdf6ea; }

/* ---------------------------------------------------------------- how each flat was placed on the map (geo.locate) */
.mapa-leyenda .punto { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: -1px; margin: 0 2px 0 4px; }
.punto-ficha { background: #d98324; border: 1.5px solid #fff; box-shadow: 0 0 0 1px #d98324; }
.punto-calle { background: #d98324; border: 1.5px dashed #1b1d21; }
.punto-barrio { background: rgba(217, 131, 36, .25); border: 2px dashed #d98324; }

/* ---------------------------------------------------------------- seguimiento.py: the negotiation log and reminders */
.chip-boton { cursor: pointer; font: inherit; }
.chip-boton:hover { background: var(--bg); }
.recordatorio-fila { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 12px; }
.recordatorio-botones { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.recordatorio-botones input[type="date"] { padding: 4px 6px; font-size: 13px; }
.seguimiento-form { margin: 0 0 4px; }
.seguimiento-hilo { margin-top: 14px; }
.lectura-oferta.ok { color: var(--good); }
.lectura-oferta.warn { color: var(--warm); }
.lectura-oferta.bad { color: var(--hot); }
.timeline li.ev-oferta::before, .timeline li.ev-contraoferta::before { background: var(--good); }
.timeline li.ev-llamada::before, .timeline li.ev-visita::before { background: var(--accent); }
.badge.recordatorio-vencido { background: #fde8e3; color: var(--hot); }
.badge.recordatorio-proximo { background: #eef3fd; color: var(--accent); }

/* ---------------------------------------------------------------- comparar.html */
.comparar-tabla .atrasado { color: var(--hot); font-weight: 600; }

/* ---------------------------------------------------------------- panel.html: «Qué hacer ahora» */
.agenda-grupo h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.agenda-grupo h3 b { font-variant-numeric: tabular-nums; }
.agenda-filas { display: flex; flex-direction: column; gap: 6px; }
.agenda-fila { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
               padding: 8px 12px; }
.agenda-que { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; color: inherit; }
.agenda-que:hover { text-decoration: none; }
.agenda-que:hover b { text-decoration: underline; }
.agenda-que .thumb { flex: none; }
.agenda-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.agenda-texto b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-cta { flex: none; }
@media (max-width: 600px) {
  .agenda-fila { flex-wrap: wrap; }
  .agenda-cta { flex: 1 1 100%; justify-content: center; }
}

/* ---------------------------------------------------------------- sortable column headers (replaces the «Orden» select
   on a computer, where the table has a thead to click; on a phone or tablet the table is cards instead, so the old
   select comes back there, in .orden-movil) */
th.th-orden { padding: 0; }
th.th-orden a { display: block; padding: 8px 9px; color: inherit; text-decoration: none; cursor: pointer; white-space: nowrap; }
th.th-orden a:hover { color: var(--accent); text-decoration: none; }
th.th-orden-activo a { color: var(--accent); }
.th-flecha { margin-left: 3px; font-size: 10px; }
.orden-movil { display: none; }
@media (max-width: 900px) { .orden-movil { display: block; } }

/* ---------------------------------------------------------------- configuracion.html: the zones of a search */
.barrios-tabla td { vertical-align: middle; }
.barrios-tabla .iconlink { margin-left: 4px; }
.nuevo-barrio { margin: 6px 0 14px; }
.barrios-lista { max-height: 460px; overflow-y: auto; }
.barrios-lista thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
.nuevo-barrio textarea { width: 100%; font-family: inherit; }
.barrios-fuera { margin-top: 12px; }
.barrios-fuera li { margin: 4px 0; }
.barrios-fuera .btn { margin-left: 8px; }
