/* Inmokalas · Asistente de compradores — estilo minimalista en blanco y negro */

:root {
  --bg: #ffffff;
  --subtle: #f6f6f5;
  --subtle-2: #efefed;
  --line: #e7e7e5;
  --line-strong: #cdcdca;
  --text: #111111;
  --muted: #6b6b68;
  --faint: #9a9a96;
  --ink: #111111;          /* botones principales */
  --on-ink: #ffffff;
  --alert: #b42318;        /* solo para avisos: atrasado, bloqueos, errores */
  --alert-soft: #fdf1ef;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --sidebar: 248px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --accent: #111111;       /* detalle de marca: pestaña activa, menú activo */
  color-scheme: light;
}

/* Tema «Compra con Pablo»: azul marino y dorado del logotipo, sobre blanco. */
html[data-theme="pablo"] {
  --ink: #13294b;
  --text: #0f1b2d;
  --muted: #5d6676;
  --faint: #98a0ad;
  --subtle: #f6f7f9;
  --subtle-2: #eceff4;
  --line: #e4e7ec;
  --line-strong: #c9ced8;
  --accent: #c8922a;
}

/* Barras translúcidas, avisos y flecha de los desplegables (cambian en modo oscuro). */
:root {
  --bar: rgba(255, 255, 255, .95);
  --alert-line: var(--alert-line);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23111' stroke-width='1.6'/%3E%3C/svg%3E");
}

/* ---------- modo oscuro (preferencia de cada dispositivo, en Ajustes → Apariencia) ---------- */
html[data-mode="dark"] {
  color-scheme: dark;
  --bg: #121212;
  --subtle: #1c1c1b;
  --subtle-2: #262624;
  --line: #2f2f2d;
  --line-strong: #474744;
  --text: #ededeb;
  --muted: #a6a6a1;
  --faint: #76766f;
  --ink: #f0f0ee;
  --on-ink: #111111;
  --accent: #f0f0ee;
  --alert: #f97066;
  --alert-soft: #3a1a17;
  --alert-line: #6b2c25;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  --bar: rgba(18, 18, 18, .94);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23ddd' stroke-width='1.6'/%3E%3C/svg%3E");
}
/* «Compra con Pablo» en oscuro: fondo azul noche y botones dorados. */
html[data-mode="dark"][data-theme="pablo"] {
  --bg: #0c1626;
  --subtle: #121f34;
  --subtle-2: #192a44;
  --line: #22334f;
  --line-strong: #3a4c6c;
  --text: #e8edf5;
  --muted: #a3afc2;
  --faint: #6f7c92;
  --ink: #d9a640;
  --on-ink: #0c1626;
  --accent: #d9a640;
  --bar: rgba(12, 22, 38, .94);
}
/* Logotipos legibles sobre fondo oscuro */
html[data-mode="dark"] img.logo-pablo { background: #fff; border-radius: 50%; }
html[data-mode="dark"] img.logo-inmokalas, html[data-mode="dark"] img.mark-inmokalas { filter: invert(1); }
/* Urgencia: mismo color de verde a rojo, pero en tonos oscuros */
html[data-mode="dark"] .urg { background: color-mix(in srgb, var(--u-border) 16%, var(--bg)) !important; }
html[data-mode="dark"] .urg-banner, html[data-mode="dark"] .urg-line { color: color-mix(in srgb, var(--u-border) 45%, #fff); }
html[data-mode="dark"] .urg .urg-badge, html[data-mode="dark"] .urg-banner .urg-badge { color: color-mix(in srgb, var(--u-border) 45%, #fff); background: rgba(0, 0, 0, .3); }
/* Selector Claro / Oscuro / Automático */
.mode-pick { display: flex; flex-wrap: wrap; gap: 8px; }

/* Logotipo según el tema */
.logo-inmokalas, .mark-inmokalas { display: none; }
html[data-theme="inmokalas"] .logo-pablo { display: none; }
html[data-theme="inmokalas"] .logo-inmokalas, html[data-theme="inmokalas"] .mark-inmokalas { display: block; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; }
a { color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: 0; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- estructura ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: var(--bar);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar img { width: 34px; height: 34px; border-radius: 50%; }
.home-link { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.sidebar .home-link { flex-direction: column; }
.topbar .title { font-weight: 650; font-size: 1rem; }
.topbar .title span { color: var(--muted); font-weight: 500; }

.sidebar { display: none; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  background: var(--bar);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottomnav .nav-link {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; font-size: .75rem; font-weight: 600; color: var(--faint); text-decoration: none; position: relative;
}
.bottomnav .nav-link svg { width: 24px; height: 24px; }
.bottomnav .nav-link { font-size: .68rem; min-width: 0; }
.nav-link[aria-current="page"] { color: var(--ink); }
.nav-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--alert); color: var(--bg); font-size: .72rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.bottomnav .nav-count { position: absolute; top: 6px; left: calc(50% + 6px); }

.main-wrap { padding: 20px 16px calc(150px + env(safe-area-inset-bottom, 0px)); }
main { max-width: 920px; margin: 0 auto; outline: none; }

.fab {
  position: fixed; z-index: 25; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 52px; padding: 0 20px; border-radius: 26px; border: 0;
  background: var(--ink); color: var(--on-ink); font: 600 1rem var(--font);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18); cursor: pointer;
}
.fab svg { width: 22px; height: 22px; }

@media (min-width: 900px) {
  .topbar, .bottomnav, .fab { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar);
    padding: 24px 16px; border-right: 1px solid var(--line); background: var(--bg);
  }
  .sidebar .brand { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 8px 20px; text-align: center; }
  .sidebar .brand img.logo-pablo { width: 112px; height: 112px; border-radius: 50%; }
  .sidebar .brand img.logo-inmokalas { width: 176px; height: auto; margin: 8px 0 4px; }
  .sidebar .brand .title { font-weight: 650; font-size: .95rem; line-height: 1.3; }
  .sidebar .brand .title span { display: block; color: var(--muted); font-weight: 500; font-size: .85rem; }
  .sidebar .nav-link {
    display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px;
    border-radius: var(--radius-sm); text-decoration: none; font-weight: 600; color: var(--muted);
  }
  .sidebar .nav-link svg { width: 22px; height: 22px; }
  .sidebar .nav-link:hover { background: var(--subtle); color: var(--text); }
  .sidebar .nav-link[aria-current="page"] { background: var(--subtle-2); color: var(--ink); box-shadow: inset 3px 0 0 var(--accent); }
  .sidebar .nav-count { margin-left: auto; }
  .sidebar .btn-assistant { margin-top: 16px; }
  .main-wrap { margin-left: var(--sidebar); padding: 36px 40px 80px; }
}

/* ---------- botones ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--text);
  font: 600 1rem var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--subtle); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn-primary:hover { background: var(--ink); filter: brightness(1.25); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { color: var(--alert); border-color: var(--alert-line); }
.btn-danger:hover { background: var(--alert-soft); }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: .9rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row > .btn { flex: 1 1 auto; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--text); cursor: pointer;
  font-size: 1.2rem;
}
.icon-btn:hover { background: var(--subtle); }
.link-btn { border: 0; background: none; padding: 0; font: inherit; color: var(--text); text-decoration: underline; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- formularios ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-size: .875rem; font-weight: 600; }
.field .hint { font-size: .8rem; color: var(--muted); }
.form { display: flex; flex-direction: column; gap: 18px; }
.form-section { display: flex; flex-direction: column; gap: 14px; padding-top: 6px; }
.form-section + .form-section { border-top: 1px solid var(--line); padding-top: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .grid-2 { grid-template-columns: 1fr; } }

input[type=text], input[type=tel], input[type=email], input[type=password], input[type=search], input[type=date], input[type=number],
select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg); color: var(--text);
  font: 16px/1.4 var(--font); appearance: none; -webkit-appearance: none;
}
input[type=date] { min-width: 0; }
textarea { min-height: 96px; resize: vertical; }
select {
  padding-right: 40px;
  background-image: var(--select-arrow);
  background-repeat: no-repeat; background-position: right 14px center;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(0, 0, 0, .08); }
.check { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding: 10px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--ink); }
.check.disabled { color: var(--faint); cursor: default; }

/* Control segmentado y chips */
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-btn, .chip {
  min-height: 44px; padding: 0 16px; border-radius: 22px;
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--text);
  font: 500 .95rem var(--font); cursor: pointer;
}
.seg-btn[aria-pressed="true"], .chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.chip { min-height: 36px; padding: 0 12px; font-size: .875rem; }
.date-field .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.date-field .preview { font-size: .85rem; color: var(--muted); margin-top: 4px; min-height: 1.2em; }

.error-box {
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--alert-soft); color: var(--alert); font-size: .92rem; border: 1px solid var(--alert-line);
}
.error-box .btn-row { margin-top: 10px; }
.notice {
  padding: 12px 14px; border-radius: var(--radius-sm); background: var(--subtle); border: 1px solid var(--line); font-size: .92rem;
}

/* ---------- tarjetas, cabeceras y listas ---------- */

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); font-size: .92rem; margin-top: 4px; }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.section { margin-top: 28px; }
.section > h3 { margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.toolbar .search { position: relative; }
.toolbar .search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--faint); }
.toolbar .search input { padding-left: 44px; }
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters .chip { flex: none; }

.buyer-list { display: flex; flex-direction: column; gap: 10px; }
.buyer-card {
  display: grid; gap: 6px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; background: var(--bg); transition: border-color .15s, box-shadow .15s;
}
.buyer-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.buyer-card .row1 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.buyer-card .name { font-weight: 650; font-size: 1.05rem; }
.buyer-card .summary { color: var(--muted); font-size: .95rem; }
.buyer-card .meta { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: .85rem; color: var(--muted); }
.buyer-card .meta b { color: var(--text); font-weight: 600; }

/* Solo lectura: se ocultan los controles de modificar (el servidor también lo impide). */
.readonly .quick, .readonly button.btn, .readonly .link-btn, .readonly .edit-only, .readonly .task select, .readonly .stages { display: none !important; }
.readonly .task .t-main { pointer-events: none; }
.only-admin { display: none; }
html.is-admin .only-admin { display: revert; }

/* Urgencia: la ficha entera se tiñe de verde a rojo según se acerca la fecha límite. */
.urg { background: var(--u-bg) !important; border-color: var(--u-border) !important; border-left: 6px solid var(--u-border) !important; }
.urg .urg-badge, .urg-banner .urg-badge { color: var(--u-text); border-color: var(--u-border); background: rgba(255, 255, 255, .7); font-weight: 700; }
.urg-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--u-text, var(--muted)); }
.urg-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 0; }
.urg-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-left: 6px; }
.urg-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: 12px; color: var(--u-text); }
.sorts .chip { min-height: 32px; }

/* Estados: siempre con texto; el estilo solo refuerza. */
.badge {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--line-strong); color: var(--text); background: var(--bg);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.st-activa { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.badge.st-pendiente_confirmar { border-style: dashed; }
.badge.st-pendiente_confirmar::before { background: transparent; border: 1.5px solid currentColor; width: 5px; height: 5px; }
.badge.st-en_pausa { color: var(--muted); background: var(--subtle); border-color: var(--line); }
.badge.st-en_compraventa { border-color: var(--ink); border-width: 1.5px; }
.badge.st-cerrada { color: var(--faint); border-color: var(--line); }
.badge.st-cerrada::before { border-radius: 1px; }
.badge.plain::before { display: none; }
.badge.test { border-style: dotted; color: var(--muted); }
.badge.alert { color: var(--alert); border-color: var(--alert-line); background: var(--alert-soft); }
.badge.stage-cancelada { color: var(--faint); text-decoration: line-through; }
.badge.stage-firmada { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

.overdue { color: var(--alert); font-weight: 600; }

/* ---------- ficha del comprador ---------- */

.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-weight: 500; margin-bottom: 12px; min-height: 36px; }
.back:hover { color: var(--text); }
.back svg { width: 18px; height: 18px; }
.buyer-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.buyer-head .title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.buyer-head .contact { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); }
.buyer-head .contact a { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.quick .btn { flex-direction: column; gap: 4px; min-height: 72px; padding: 8px; font-size: .88rem; white-space: normal; text-align: center; line-height: 1.2; }
.quick .btn svg { width: 22px; height: 22px; }

.next-box {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius); background: var(--subtle); border: 1px solid var(--line);
}
.next-box.is-overdue { background: var(--alert-soft); border-color: var(--alert-line); }
.next-box .what { font-weight: 600; }
.next-box .when { font-size: .9rem; color: var(--muted); }
.next-box.is-overdue .when { color: var(--alert); font-weight: 600; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: .88rem; color: var(--muted); margin-top: 10px; }
.facts b { color: var(--text); font-weight: 600; }

.tabs { display: flex; border-bottom: 1px solid var(--line); margin: 22px 0 18px; }
.tab {
  flex: 1; min-height: 50px; border: 0; background: none; cursor: pointer;
  font: 600 1rem var(--font); color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.info { display: grid; grid-template-columns: minmax(150px, 34%) 1fr; gap: 12px 18px; margin: 0; }
.info dt { color: var(--muted); font-size: .9rem; }
.info dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.info dd.unconfirmed { color: var(--faint); font-style: italic; }
@media (max-width: 560px) {
  .info { grid-template-columns: 1fr; gap: 2px; }
  .info dd { margin-bottom: 12px; }
}
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }

/* Historial */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 20px; border-left: 1px solid var(--line); margin-left: 5px; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--bg); border: 1.5px solid var(--ink); }
.timeline li:last-child { border-left-color: transparent; }
.timeline .when { font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.timeline .kind { font-weight: 600; color: var(--text); }
.timeline .text { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline .changes { margin: 6px 0 0; padding: 0; list-style: none; font-size: .88rem; color: var(--muted); }
.timeline .changes li { border: 0; padding: 0; margin: 0; }
.timeline .changes li::before { display: none; }
.timeline .changes b { color: var(--text); font-weight: 600; }

/* Compraventa */
.stages { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 16px; }
.stages .seg-btn { min-height: 40px; font-size: .88rem; padding: 0 12px; }
.stages .seg-btn.done { border-color: var(--ink); }
.blockers { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--alert-soft); color: var(--alert); border: 1px solid var(--alert-line); white-space: pre-wrap; }
.task-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.task { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); }
.task:first-child { border-top: 0; }
.task .t-main { flex: 1; min-width: 0; background: none; border: 0; text-align: left; padding: 6px 0; cursor: pointer; font: inherit; color: inherit; }
.task .t-title { font-weight: 600; }
.task .t-meta { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task.is-hecha .t-title, .task.is-no_aplica .t-title { text-decoration: line-through; color: var(--faint); }
.task select { width: auto; min-height: 40px; font-size: .88rem; padding: 6px 34px 6px 10px; background-position: right 10px center; }
details.deal-old { border: 1px solid var(--line); border-radius: var(--radius); }
details.deal-old + details.deal-old { margin-top: 10px; }
details.deal-old > summary { cursor: pointer; padding: 14px 18px; font-weight: 600; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
details.deal-old > summary::-webkit-details-marker { display: none; }
details.deal-old > summary::after { content: "Ver"; margin-left: auto; font-weight: 500; color: var(--muted); font-size: .9rem; }
details.deal-old[open] > summary::after { content: "Ocultar"; }
details.deal-old > .card { border: 0; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }

/* Pendientes */
.p-item { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); }
.p-item + .p-item { margin-top: 8px; }
.p-item .p-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; }
.p-item .p-who { font-weight: 650; text-decoration: none; }
.p-item .p-who:hover { text-decoration: underline; }
.p-item .p-what { color: var(--text); }
.p-item .p-when { font-size: .88rem; color: var(--muted); }
.p-item .p-when.overdue { color: var(--alert); }
.p-item .btn-row .btn { flex: 0 1 auto; }
.count-pill { display: inline-flex; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--subtle-2); color: var(--text); font-size: .78rem; font-weight: 700; align-items: center; justify-content: center; letter-spacing: 0; }
.count-pill.alert { background: var(--alert); color: var(--bg); }

/* Ajustes */
.setting { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; }
.setting .s-text { flex: 1 1 260px; }
.setting .s-title { font-weight: 600; }
.setting .s-desc { font-size: .88rem; color: var(--muted); }

/* ---------- hojas (diálogos) ---------- */

dialog.sheet {
  border: 0; padding: 0; color: var(--text); background: var(--bg);
  width: min(620px, calc(100vw - 32px)); max-height: min(88vh, 900px);
  border-radius: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  display: flex; flex-direction: column; overflow: hidden;
}
dialog.sheet:not([open]) { display: none; }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .35); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 12px 22px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 1.1rem; }
.sheet-body { padding: 18px 22px 22px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end;
  padding: 12px 22px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--bg);
}
.sheet-foot .btn { flex: 1 1 auto; }
@media (min-width: 560px) { .sheet-foot .btn { flex: 0 0 auto; } }
@media (max-width: 559px) {
  dialog.sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; max-height: 92dvh; border-radius: 20px 20px 0 0; }
}

/* ---------- inicio (resumen) ---------- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: inherit; background: var(--bg); }
.kpi:hover { border-color: var(--line-strong); }
.kpi-value { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.kpi-label { font-size: .88rem; color: var(--muted); font-weight: 600; }
.kpi-hint { font-size: .78rem; color: var(--muted); }
.kpi.is-alert { border-color: var(--alert-line); background: var(--alert-soft); }
.kpi.is-alert .kpi-value, .kpi.is-alert .kpi-label { color: var(--alert); }

.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 14px 0 6px; }
.quick-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; min-width: 0; white-space: nowrap; }
.quick-btn svg { width: 18px; height: 18px; flex: none; }

.home-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
@media (min-width: 900px) { .home-grid { grid-template-columns: 1fr 1fr; } }
.home-grid .card + .card { margin-top: 0; }
.home-card h2 { font-size: 1.05rem; }
.home-wide { grid-column: 1 / -1; }
.warn-text { color: var(--alert); margin-top: 2px; }
.h-row { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; padding: 9px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.h-row:first-child { border-top: 0; padding-top: 0; }
.h-row:hover .h-main b { text-decoration: underline; }
.h-main { min-width: 0; flex: 1 1 220px; overflow-wrap: anywhere; }
.h-side { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.h-side.overdue { color: var(--alert); }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 40%) 1fr 32px; align-items: center; gap: 10px; font-size: .9rem; }
.bar-track { height: 8px; border-radius: 4px; background: var(--subtle-2); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--ink); border-radius: 4px; }
.bar-value { text-align: right; font-weight: 700; }

/* ---------- acceso ---------- */

.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login .box { width: min(400px, 100%); display: flex; flex-direction: column; gap: 18px; text-align: center; }
.login img.logo-pablo { width: 180px; height: 180px; margin: 0 auto; border-radius: 50%; }
.login img.logo-inmokalas { width: 240px; height: auto; margin: 12px auto; }
/* Acceso: foto de Villajoyosa a pantalla completa (4K en pantallas grandes) con el recuadro de acceso encima. */
.login {
  position: relative;
  background: #2b3a4a url(/brand/fondo-villajoyosa-movil.jpg) 28% center / cover no-repeat;
}
@media (min-width: 1000px), (min-width: 700px) and (min-resolution: 2dppx) {
  .login { background-image: url(/brand/fondo-villajoyosa-4k.jpg); }
}
.login::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.10), rgba(0,0,0,.35));
  /* Fondo ligeramente difuminado para que destaque el recuadro de acceso. */
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
}
.login .box {
  position: relative; z-index: 1;
  background: var(--bg); padding: 28px 24px; border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.photo-credit {
  position: absolute; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 1;
  font-size: .7rem; color: rgba(255,255,255,.85); text-decoration: none; text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.photo-credit:hover { text-decoration: underline; }
/* Inmokalas como imagen principal; «Compra con Pablo» pequeño y discreto debajo. */
.login img.login-main { width: 260px; max-width: 80%; height: auto; margin: 12px auto 0; }
html[data-mode="dark"] .login img.login-main { filter: invert(1); }
.login-alt { display: flex; align-items: center; justify-content: center; gap: 8px; opacity: .7; font-size: .8rem; color: var(--muted, #666); }
.login-alt img { width: 32px; height: 32px; border-radius: 50%; }
html[data-mode="dark"] .login-alt img { background: #fff; }
.topbar img.mark-inmokalas { border-radius: 8px; }

.admin-title { margin: 32px 0 12px; font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
section.card + section.card, section.card + .admin-title + section.card { margin-top: 12px; }

/* Selector de tema en Ajustes */
.theme-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.theme-opt { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--bg); cursor: pointer; font: inherit; text-align: left; color: var(--text); }
.theme-opt[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(0, 0, 0, .06); }
.theme-opt img { width: 48px; height: 48px; object-fit: contain; flex: none; }
.theme-opt .sw { display: flex; gap: 4px; margin-top: 4px; }
.theme-opt .sw i { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line-strong); }

/* Inmuebles */
.prop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.prop { position: relative; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg); }
.prop.selected { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.prop .ph { position: relative; aspect-ratio: 4 / 3; background: var(--subtle-2); overflow: hidden; }
.prop .ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.prop .pi { padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.prop .price { font-weight: 700; font-size: 1.1rem; }
.prop .facts { color: var(--muted); font-size: .88rem; }
.prop .ttl { font-weight: 600; font-size: .95rem; }
.prop .why { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.prop .why .warn { color: var(--alert); }
.prop .pa { display: flex; gap: 6px; padding: 0 14px 12px; flex-wrap: wrap; }
.prop .pick { position: absolute; top: 10px; left: 10px; width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; background: rgba(0, 0, 0, .35); color: #fff; font-weight: 700; cursor: pointer; }
.prop.selected .pick { background: var(--ink); color: var(--on-ink); }
.prop.hidden-public .ph { opacity: .45; }
.prop-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.prop-filters select, .prop-filters input { min-height: 44px; font-size: .95rem; }
.prop .open { display: block; text-decoration: none; color: inherit; flex: 1; }
.prop .open:hover .ttl { text-decoration: underline; }

/* Ficha del inmueble */
.pd-price { font-size: 1.6rem; font-weight: 750; color: var(--ink); white-space: nowrap; }
.pd-price .old { font-size: .95rem; font-weight: 500; color: var(--faint); text-decoration: line-through; margin-left: 8px; }
.pd-gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; border-radius: var(--radius); overflow: hidden; }
.pd-photo { position: relative; aspect-ratio: 4 / 3; padding: 0; border: 0; background: var(--subtle-2); cursor: zoom-in; overflow: hidden; }
.pd-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.pd-photo:hover img { transform: scale(1.03); }
.pd-photo.main { grid-column: span 2; grid-row: span 2; }
.pd-gallery .pd-photo:nth-child(n+8) { display: none; }
@media (max-width: 620px) { .pd-gallery { grid-template-columns: repeat(3, 1fr); } .pd-photo.main { grid-column: span 3; grid-row: auto; } }
.pd-map { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--subtle-2); }
.pd-map iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.pd-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pd-desc { white-space: pre-wrap; line-height: 1.6; }
.paper { width: 40px; height: 40px; flex: none; position: relative; }
.paper::before { content: ""; position: absolute; border: 2px solid var(--ink); border-radius: 3px; background: var(--bg); }
.paper.vertical::before { width: 28px; height: 40px; left: 6px; top: 0; }
.paper.horizontal::before { width: 40px; height: 28px; left: 0; top: 6px; }

/* Asistente (conversación) */
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 45vh; overflow-y: auto; padding: 4px 2px; }
.bubble { max-width: 88%; padding: 10px 12px; border-radius: 14px; font-size: .95rem; }
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; background: var(--ink); color: var(--on-ink); border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--subtle-2); border-bottom-left-radius: 4px; }

/* Visor de fotos */
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, .94); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px); }
.lightbox img { max-width: 100vw; max-height: calc(100dvh - 90px); object-fit: contain; user-select: none; }
.lb-count { color: #ddd; font-size: .9rem; margin-top: 10px; }
.lb-btn { position: absolute; width: 54px; height: 54px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .14); color: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer; }
.lb-btn:hover { background: rgba(255, 255, 255, .28); }
.lb-close { top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; }
.lb-prev { left: 10px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 10px; top: 50%; transform: translateY(-50%); }

/* Subida de fotos (inmuebles propios) */
.up-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.up-item { position: relative; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--subtle-2); }
.up-item img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.up-item .up-tools { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; padding: 4px; background: linear-gradient(transparent, rgba(0, 0, 0, .55)); }
.up-item .up-tools button { width: 32px; height: 32px; border: 0; border-radius: 8px; background: rgba(255, 255, 255, .9); cursor: pointer; font-size: .95rem; }
.up-item .cover { position: absolute; top: 6px; left: 6px; background: var(--ink); color: var(--on-ink); font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.up-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; aspect-ratio: 4 / 3; border: 2px dashed var(--line-strong); border-radius: 10px; color: var(--muted); cursor: pointer; text-align: center; font-size: .88rem; padding: 8px; }
.up-drop:hover { border-color: var(--ink); color: var(--ink); }

.selbar { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 24; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; margin-top: 14px; border-radius: var(--radius); background: var(--ink); color: var(--on-ink); box-shadow: 0 6px 20px rgba(0, 0, 0, .2); }
.selbar .btn { background: var(--bg); color: var(--text); border-color: var(--bg); }
@media (min-width: 900px) { .selbar { bottom: 16px; } }
.share-box { display: flex; flex-direction: column; gap: 10px; }
.share-box input { font-size: .9rem; }
.login .form { text-align: left; }

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

#toasts {
  position: fixed; z-index: 100; left: 50%; transform: translateX(-50%);
  top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--on-ink);
  font-size: .95rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: toast-in .2s ease-out;
}
.toast.error { background: #b42318; color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

.loading { padding: 40px 0; text-align: center; color: var(--muted); }
