/* Layout and components (same look as the original ObraMap) */

/* ── Topbar ── */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0; z-index: 1000; position: relative;
}
.logo { font-family: var(--fh); font-size: 19px; font-weight: 800; letter-spacing: -.5px; white-space: nowrap; color: var(--text); }
.logo span { color: var(--accent); }

/* category strip (ui.js initFilterScroll): scrolls sideways, no scrollbar, fade + ‹ › only where there is more */
.filters-wrap { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.filters {
  display: flex; gap: 7px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 2px 0;
  --fl: 0px; --fr: 0px;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--fl), #000 calc(100% - var(--fr)), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--fl), #000 calc(100% - var(--fr)), transparent);
}
.filters::-webkit-scrollbar { display: none; }
.filters-wrap.can-prev .filters { --fl: 40px; }
.filters-wrap.can-next .filters { --fr: 40px; }
.filters-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 1; display: none;
  width: 26px; height: 26px; padding: 0 0 2px; border-radius: 50%; cursor: pointer;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  font: 600 17px/1 var(--fb); align-items: center; justify-content: center;
}
.filters-arrow:hover { border-color: var(--accent); color: var(--accent); }
.filters-arrow.prev { left: 0; }
.filters-arrow.next { right: 0; }
.filters-wrap.can-prev .filters-arrow.prev, .filters-wrap.can-next .filters-arrow.next { display: flex; }
@media (hover: none) { .filters-wrap .filters-arrow { display: none; } } /* touch: swipe */
.filter-btn {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  background: var(--surface2); border: 1px solid var(--border); color: var(--dim);
  border-radius: 20px; padding: 4px 13px 4px 9px; font-family: var(--fb); font-size: 12px; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.filter-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ── Numbers: Syne's "1" is very wide; counters and prices use Inter with equal-width figures ── */
body :is(.job-count #countNum, .card-price, .detail-price, .quote-price, .tpl-price, .count-badge, .adm-stat-n) {
  font-family: var(--fb); font-variant-numeric: tabular-nums lining-nums; letter-spacing: -.02em;
}
body :is(.job-count #countNum, .detail-price, .quote-price, .adm-stat-n) { font-weight: 800; }

/* ── Icons (assets/icons, 64 px WebP): decorative, centred with their text ── */
.ic { display: inline-block; flex-shrink: 0; object-fit: contain; vertical-align: middle; }
.tag .ic { margin: -3px 0; }
.tag-cat { gap: 5px; }
.detail-cat { display: flex; align-items: center; gap: 7px; }
.empty-icon .ic { display: block; margin: 0 auto; }
.conv-job .ic, .ic-inline, #jobFilterBar .ic { margin-right: 5px; vertical-align: -3px; }
.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 600; }

.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; margin-left: auto; }

.user-badge {
  display: flex; align-items: center; gap: 7px; padding: 3px 11px 3px 4px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; color: var(--text);
}
.avatar {
  width: 27px; height: 27px; background: var(--accent); border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: #000;
}
.uname { font-size: 13px; font-weight: 500; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Main layout ── */
.main { display: flex; flex: 1; overflow: hidden; position: relative; }
#map { flex: 1; background: var(--surface); }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden; z-index: 1050;
}
.sheet-handle { display: none; }
.sidebar-head { padding: 14px 18px 12px; border-bottom: 1px solid var(--border); }
.sidebar-label {
  font-family: var(--fh); font-size: 11px; font-weight: 700; color: var(--dim);
  letter-spacing: 1.5px; text-transform: uppercase;
}
.job-count { font-size: 26px; font-family: var(--fh); font-weight: 800; color: var(--accent); line-height: 1.1; margin-top: 3px; }
.job-count small { font-size: 13px; font-weight: 400; color: var(--dim); font-family: var(--fb); }

.seg { display: flex; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 3px; margin-bottom: 12px; }
.seg button {
  flex: 1; background: none; border: none; color: var(--dim); padding: 5px 6px; border-radius: 6px;
  font-size: 12px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.seg button.active { background: var(--accent); color: #000; }

.side-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }
.side-filters .fi { padding: 6px 10px; font-size: 12px; }
.side-filters .full { grid-column: 1 / -1; }
.near-btn.active { border-color: var(--accent); color: var(--accent); }

.jobs-list { flex: 1; overflow-y: auto; padding: 8px; }

/* ── Cards ── */
.job-card {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r);
  padding: 13px 15px; margin-bottom: 7px; cursor: pointer; transition: border-color .15s, transform .15s;
}
.job-card:hover { border-color: var(--accent); transform: translateX(2px); }
.job-card.active { border-color: var(--accent); background: #1f1c14; }
.card-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.card-title { font-family: var(--fh); font-size: 13px; font-weight: 600; line-height: 1.3; flex: 1; }
.card-price { font-family: var(--fh); font-size: 13px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.card-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.card-desc {
  font-size: 12px; color: var(--dim); line-height: 1.5; margin-top: 7px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-date { font-size: 11px; color: var(--dimmer); margin-top: 7px; }
.pro-card { display: flex; gap: 11px; }
.pro-card .avatar { width: 40px; height: 40px; font-size: 16px; }
.pro-card .body { flex: 1; min-width: 0; }

/* ── Detail panel ── */
.detail {
  position: absolute; right: 20px; bottom: calc(20px + var(--cookie-h, 0px)); width: 350px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px;
  z-index: 1100; box-shadow: var(--shadow);
  transform: translateY(20px); opacity: 0; pointer-events: none;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s;
  max-height: calc(100% - 40px - var(--cookie-h, 0px)); overflow-y: auto;
}
.detail.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.detail-close {
  position: absolute; top: 10px; right: 10px; background: var(--surface2); border: none; color: var(--dim);
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.detail-close:hover { color: var(--text); }
.detail-cat { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.detail-title { font-family: var(--fh); font-size: 18px; font-weight: 700; line-height: 1.25; margin-bottom: 10px; padding-right: 24px; }
.detail-price { font-family: var(--fh); font-size: 26px; font-weight: 800; color: var(--accent); margin-bottom: 14px; }
.detail-price small { font-size: 13px; font-weight: 400; color: var(--dim); font-family: var(--fb); }
.detail-desc { font-size: 13px; line-height: 1.6; color: #bbb; margin-bottom: 16px; white-space: pre-line; }
.detail-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.detail-actions { display: flex; flex-direction: column; gap: 7px; }
.contact-box { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 11px 13px; font-size: 13px; line-height: 1.7; }

/* ── Modals ── */
.overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 2000;
  align-items: center; justify-content: center; backdrop-filter: blur(4px); padding: 16px;
}
.overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px;
  width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow);
}
.modal-wide { max-width: 520px; }
.modal-title { font-family: var(--fh); font-size: 20px; font-weight: 700; margin-bottom: 22px; }
.modal-title span { color: var(--accent); }
.mf { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 20px; }
.mf .btn { flex: 1 1 auto; } /* auto basis: long labels wrap to a new row instead of overflowing */

.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab {
  flex: 1; text-align: center; padding: 9px; font-size: 14px; font-weight: 500; color: var(--dim);
  cursor: pointer; border: none; background: none; border-bottom: 2px solid transparent;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.auth-meta { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.link-btn {
  background: none; border: none; padding: 0; color: var(--accent); cursor: pointer;
  font: inherit; font-size: 13px; text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { opacity: .85; }
#tForgot .muted, #askOverlay .muted { margin-bottom: 14px; }

.auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; }
.auth-divider hr { flex: 1; border: none; border-top: 1px solid var(--border); }
.auth-divider span { color: var(--dimmer); font-size: 12px; white-space: nowrap; }
.google-btn {
  width: 100%; padding: 10px 16px; background: #fff; border: 1px solid #dadce0; border-radius: 8px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 14px; font-family: var(--fb); color: #3c4043; transition: background .15s, box-shadow .15s;
}
.google-btn:hover:not(:disabled) { background: #f7f8f8; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.google-btn:disabled { opacity: .45; cursor: not-allowed; }
.google-off { text-align: center; margin-top: 8px; font-size: 12px; color: var(--dim); }

/* address autocomplete */
.suggest {
  position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; z-index: 10;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  max-height: 220px; overflow-y: auto; box-shadow: var(--shadow);
}
.suggest button {
  display: block; width: 100%; text-align: left; background: none; border: none; color: var(--text);
  padding: 9px 12px; font-size: 12px; cursor: pointer; border-bottom: 1px solid var(--border);
}
.suggest button:last-child { border-bottom: none; }
.suggest button:hover, .suggest button.hl { background: #2e2a20; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 28px; left: 50%; z-index: 9999; max-width: calc(100% - 32px);
  transform: translateX(-50%) translateY(90px);
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 22px; font-size: 13px; pointer-events: none;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red); color: #ff8070; }

/* ── Loading ── */
.loading {
  position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column;
  align-items: center; justify-content: center; z-index: 5000; transition: opacity .4s;
}
.loading.out { opacity: 0; pointer-events: none; }
.spin {
  width: 38px; height: 38px; border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; margin-bottom: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-txt { font-family: var(--fh); font-size: 13px; color: var(--dim); }

/* ── Empty state ── */
.empty { text-align: center; padding: 36px 16px; color: var(--dimmer); }
.empty-icon { font-size: 30px; margin-bottom: 10px; }
.empty-txt { font-size: 12px; line-height: 1.5; }

/* ── Map pins ── */
.pin { background: none; border: none; }
.pin-b {
  width: 40px; height: 40px; background: var(--surface);
  border: 2px solid var(--c, var(--accent)); border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  box-shadow: 0 4px 12px rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center;
}
.pin-ic { transform: rotate(45deg); width: 28px; height: 28px; }
.pin.active .pin-b { border: 3px solid #fff; transform: rotate(-45deg) scale(1.2); }
.pin-pro .pin-b { border-radius: 50%; }
.pin-pro .pin-ic { transform: none; }
.pin-me { width: 16px; height: 16px; background: #60a5fa; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 6px rgba(96,165,250,.25); }

.marker-cluster { background: rgba(245,166,35,.25); border-radius: 50%; }
.marker-cluster div {
  width: 30px; height: 30px; margin: 5px; border-radius: 50%; background: var(--accent);
  color: #000; font: 700 12px/30px var(--fh); text-align: center; box-shadow: 0 2px 10px rgba(0,0,0,.5);
}

/* ── Leaflet theme ── */
.tiles-dark { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9) saturate(.6); }
.leaflet-container { font-family: var(--fb); background: var(--surface); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); }
.leaflet-popup-content-wrapper { border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.leaflet-control-zoom a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
.leaflet-control-attribution { background: rgba(15,15,15,.7) !important; color: var(--dimmer) !important; }
.leaflet-control-attribution a { color: var(--dim) !important; }

/* ── Site footer (legal links, filled by ui.js into every [data-site-footer]) ── */
.site-foot {
  display: flex; flex-wrap: wrap; gap: 2px 14px; justify-content: center; align-items: center;
  padding: 14px 16px 18px; font-size: 11px; color: var(--dimmer);
}
.site-foot a { color: var(--dim); padding: 4px 0; }
.site-foot a:hover { color: var(--accent); }
.sidebar .site-foot, .chat-list .site-foot { padding: 6px 10px; gap: 2px 10px; border-top: 1px solid var(--border); flex-shrink: 0; }
/* page footers can always scroll out from under the cookie banner (--cookie-h is set by consent.js) */
.page > .site-foot { padding-bottom: calc(18px + var(--cookie-h, 0px)); }

/* ── Legal pages (aviso legal, privacidad, cookies, términos) ── */
.legal { max-width: 760px; line-height: 1.65; font-size: 14px; color: #d6d2cc; }
.legal h1 { font-family: var(--fh); font-size: clamp(26px, 6vw, 34px); font-weight: 800; color: var(--text); margin: 6px 0 4px; }
.legal h2 { font-family: var(--fh); font-size: 18px; font-weight: 700; color: var(--text); margin: 28px 0 8px; }
.legal h3 { font-size: 14px; font-weight: 600; color: var(--text); margin: 16px 0 6px; }
.legal p, .legal ul, .legal ol { margin-bottom: 10px; }
.legal ul, .legal ol { padding-left: 20px; }
.legal li { margin-bottom: 4px; }
.legal a { text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.legal code { font-size: 12px; background: var(--surface2); padding: 1px 5px; border-radius: 4px; }
.legal-draft {
  background: #2a2414; border: 1px solid #3a3220; color: var(--accent);
  border-radius: var(--r); padding: 10px 14px; font-size: 13px; font-weight: 500;
}
.legal-updated { color: var(--dim); font-size: 12px; }
.legal-ph { background: #3a3220; color: var(--accent); padding: 0 4px; border-radius: 3px; }
.legal-table-wrap { overflow-x: auto; margin: 10px 0 14px; border: 1px solid var(--border); border-radius: var(--r); }
.legal-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
.legal-table th, .legal-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.legal-table th { background: var(--surface); color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.legal-table tr:last-child td { border-bottom: none; }
.legal-links { margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--dimmer); }

/* ── Cookie notice (informational: only technical cookies, so no consent buttons are needed) ── */
/* Cookie banner + settings (consent.js). «Rechazar todo» and «Aceptar todo» share one style (AEPD) */
.cookie-banner { /* desktop: bottom right over the map (the sidebar footer at the left stays free) */
  position: fixed; right: 16px; bottom: 16px; z-index: 1200; width: min(460px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 14px 16px; font-size: 13px; line-height: 1.5; color: var(--dim);
}
.cookie-banner b { color: var(--text); }
.cookie-banner a { color: var(--accent); }
.cookie-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.cookie-actions .btn { flex: 1 1 110px; min-height: 42px; justify-content: center; }
.ck-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer; }
.ck-row input { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; accent-color: var(--accent); }
.ck-row input:disabled { opacity: .6; }
#cookieOverlay .hint { margin-top: 10px; }
#cookieOverlay .mf { flex-wrap: wrap; }
#cookieOverlay .mf .btn { flex: 1 1 120px; justify-content: center; }
.link-btn { background: none; border: 0; color: var(--dim); font-size: inherit; cursor: pointer; padding: 4px 0; }
.link-btn:hover { color: var(--accent); }
.legal .link-btn { color: var(--accent); padding: 0; }
@media (max-width: 768px) {
  .cookie-banner { left: 8px; right: 8px; width: auto; bottom: max(8px, env(safe-area-inset-bottom)); }
  .site-foot .link-btn { min-height: 40px; }
}

/* ── Google sign-in popup result (api/google.py) ── */
.oauth-page { min-height: 100vh; display: grid; place-items: center; }
.oauth-box { max-width: 420px; padding: 24px; text-align: center; line-height: 1.5; }
.oauth-box .logo { display: inline-block; margin-bottom: 14px; }

/* ── Error pages (404 / 500) ── */
.err-page { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 16px; text-align: center; }
.err-code { font-family: var(--fh); font-size: clamp(64px, 18vw, 120px); font-weight: 800; line-height: 1; color: var(--accent); letter-spacing: -2px; }
.err-title { font-family: var(--fh); font-size: 22px; font-weight: 700; margin: 12px 0 8px; }
.err-page .muted { max-width: 380px; margin: 0 auto 22px; line-height: 1.6; }
.err-page .row { justify-content: center; }

/* ── Simple pages (profile, dashboard) ── */
.page { flex: 1; overflow-y: auto; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 28px 20px 60px; }
.h1 { font-family: var(--fh); font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.h2 { font-family: var(--fh); font-size: 16px; font-weight: 700; margin: 26px 0 12px; }
.h3 { font-size: 13px; font-weight: 600; margin: 18px 0 4px; }
.account-box .ck-row:last-of-type { border-bottom: 0; }
.account-actions { margin-top: 10px; }
.account-actions .btn { flex: 1 1 200px; justify-content: center; }
.consent-row { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-size: 12px; line-height: 1.5; color: var(--dim); cursor: pointer; }
.consent-row input { width: 18px; height: 18px; margin-top: 1px; flex-shrink: 0; accent-color: var(--accent); }
.consent-row a { color: var(--accent); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--dim); font-size: 13px; }
.list-item {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r);
  padding: 13px 15px; margin-bottom: 8px; display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
}
.list-item .grow { flex: 1; min-width: 0; }
.job-side { text-align: right; }
.job-side .btn { margin-top: 8px; }
.list-item .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-check { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 20px; cursor: pointer; color: var(--dim); }
.chip-check:has(input:checked) { border-color: var(--accent); color: var(--text); background: #1f1c14; }
.chip-check input { accent-color: var(--accent); }
.mini-map { height: 220px; border-radius: 10px; border: 1px solid var(--border); }

.star-input { display: flex; gap: 4px; }
.star-input button { background: none; border: none; font-size: 30px; color: var(--dimmer); cursor: pointer; line-height: 1; padding: 2px; }
.star-input button.on, .star-input button:hover { color: var(--accent); }

/* ── Messenger ── */
.msg-btn { position: relative; }
.count-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.msg-btn .count-badge { position: absolute; top: -6px; right: -6px; border: 2px solid var(--bg); }
.card-actions { margin-top: 9px; }
.avatar-img { object-fit: cover; padding: 0; }

.chat-layout { display: flex; flex: 1; overflow: hidden; }
.chat-list {
  width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden;
}
.conv-items { flex: 1; overflow-y: auto; padding: 6px; }
.conv-item {
  width: 100%; display: flex; gap: 11px; align-items: center; text-align: left; padding: 11px 12px; margin-bottom: 4px;
  background: transparent; border: 1px solid transparent; border-radius: var(--r); color: var(--text); cursor: pointer;
}
.conv-item:hover { background: var(--surface2); }
.conv-item.active { background: #1f1c14; border-color: var(--accent); }
.conv-item .avatar { width: 42px; height: 42px; font-size: 15px; }
.conv-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.conv-name { font-family: var(--fh); font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 11px; color: var(--dimmer); flex-shrink: 0; }
.conv-job { font-size: 11px; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-prev { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item.unread .conv-prev { color: var(--text); font-weight: 500; }

.chat-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.chat-placeholder { margin: auto; }
.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head {
  display: flex; align-items: center; gap: 11px; padding: 10px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.chat-head .avatar { width: 38px; height: 38px; font-size: 14px; }
.chat-head .grow { flex: 1; min-width: 0; }
.chat-name { font-family: var(--fh); font-weight: 700; font-size: 15px; }
.chat-name a { color: var(--text); }
.chat-name a:hover { color: var(--accent); }
.chat-sub { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.chat-back { display: none; }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 170px; padding: 5px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow);
}
.menu button {
  display: block; width: 100%; text-align: left; padding: 8px 11px; background: none; border: none; border-radius: 6px;
  color: var(--text); font-size: 13px; cursor: pointer;
}
.menu button:hover { background: #2e2a20; }

/* deal bar: pinned between the messages and the composer */
.deal-bar {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding: 10px 16px;
  background: #17150f; border-top: 1px solid #3a3220; flex-shrink: 0;
}
.deal-bar.has-action { border-top: 2px solid var(--accent); box-shadow: 0 -6px 18px rgba(245,166,35,.08); }
.deal-status { flex: 1 1 260px; min-width: 0; }
.deal-title { font-family: var(--fh); font-size: 14px; font-weight: 700; color: var(--text); }
.deal-info { font-size: 12px; color: #d8c79f; line-height: 1.45; margin-top: 2px; }
.deal-steps { display: flex; gap: 4px; list-style: none; margin-bottom: 6px; }
.deal-steps li {
  flex: 1; max-width: 110px; font-size: 10px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase;
  color: var(--dimmer); padding-top: 5px; border-top: 3px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.deal-steps li.done { color: var(--green); border-top-color: var(--green); }
.deal-steps li.next { color: var(--accent); border-top-color: var(--accent); }
.deal-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; flex-shrink: 0; }
.deal-main { min-height: 46px; padding: 10px 22px; font-size: 15px; font-weight: 700; border-radius: var(--r); }
.deal-actions .btn:not(.deal-main) { min-height: 40px; }
.deal-bar.pulse .deal-main { animation: deal-pulse 1.4s ease-in-out 3; }
@keyframes deal-pulse { 50% { box-shadow: 0 0 0 6px rgba(245,166,35,.35); } }
@media (prefers-reduced-motion: reduce) { .deal-bar.pulse .deal-main { animation: none; outline: 2px solid var(--accent); outline-offset: 2px; } }
.deal-hint {
  display: flex; gap: 10px; align-items: center; padding: 8px 16px; font-size: 12px; line-height: 1.45;
  background: #2a2414; color: var(--text); border-top: 1px solid #3a3220; flex-shrink: 0;
}
.deal-hint .grow { flex: 1; min-width: 0; }
.deal-hint .btn { flex-shrink: 0; }

.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.load-more { align-self: center; margin-bottom: 8px; }
.msg-day {
  align-self: center; font-size: 11px; color: var(--dimmer); background: var(--surface); border: 1px solid var(--border);
  padding: 3px 10px; border-radius: 12px; margin: 10px 0 4px;
}
.msg { display: flex; flex-direction: column; max-width: min(78%, 520px); }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.bubble { padding: 8px 12px 6px; border-radius: 14px; font-size: 14px; line-height: 1.45; }
.mine .bubble { background: #3a2c10; border: 1px solid #5a4418; border-bottom-right-radius: 4px; }
.theirs .bubble { background: var(--surface2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-photo { display: block; max-width: 260px; max-height: 260px; border-radius: 9px; margin-bottom: 4px; object-fit: cover; }
.msg-meta { font-size: 10px; color: var(--dim); text-align: right; margin-top: 3px; }
.ticks { letter-spacing: -2px; margin-left: 2px; }
.ticks.read { color: var(--accent); }
.msg-warn { font-size: 11px; color: var(--accent); margin-top: 3px; }
.msg-sys {
  align-self: center; max-width: 90%; text-align: center; font-size: 12px; color: #bbb; line-height: 1.5;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--r); padding: 7px 12px; margin: 4px 0;
  white-space: pre-wrap; overflow-wrap: anywhere; /* reminders and summaries can be multi-line */
}
.quote-card {
  background: var(--surface); border: 1px solid var(--accent); border-radius: 14px; padding: 13px 15px; min-width: 240px;
}
.quote-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.quote-head .detail-cat { margin: 0; }
.quote-price { font-family: var(--fh); font-size: 24px; font-weight: 800; color: var(--accent); margin: 4px 0 2px; }

.msg-auto { font-size: 10px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 3px; }
.tag-fast { background: #2a2414; color: var(--accent); border: 1px solid #3a3220; }

/* list filters + typing / presence */
.conv-filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-top: 10px; padding-bottom: 2px; }
.conv-filters::-webkit-scrollbar { display: none; }
.conv-filters .filter-btn { flex-shrink: 0; }
.conv-filters .filter-btn:not([data-count=""])[data-count]::after {
  content: attr(data-count); margin-left: 5px; font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 8px;
  background: var(--border); color: var(--text);
}
.conv-filters .filter-btn.active::after { background: #0003; color: #000; }
.job-filter {
  display: flex; gap: 8px; align-items: center; margin-top: 10px; padding: 7px 10px; font-size: 12px;
  background: #1f1c14; border: 1px solid #3a3220; border-radius: var(--r); color: var(--accent);
}
.job-filter .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-filter a { color: var(--text); white-space: nowrap; }
.conv-prev.typing, .chat-status.typing { color: var(--accent); font-style: italic; }
.chat-status { font-size: 11px; color: var(--dimmer); margin-top: 1px; min-height: 0; }
.chat-status:empty { display: none; }
.chat-status.online { color: var(--green); }

/* info request card */
.info-card { min-width: min(300px, 100%); }
.info-list { list-style: none; margin: 8px 0 2px; padding: 0; font-size: 13px; }
.info-list li { padding: 2px 0; }
.info-list li::before { content: "☐ "; color: var(--dim); }
.info-list li.done::before { content: "☑ "; color: var(--green); }
.info-answers { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); display: grid; gap: 4px; font-size: 13px; }
.info-ans { display: flex; justify-content: space-between; gap: 12px; }
.info-ans b { font-weight: 500; text-align: right; overflow-wrap: anywhere; white-space: pre-wrap; }
.info-form { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.info-form .form-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.info-form .fg { margin-bottom: 8px; }
.info-form .fi { padding: 7px 10px; font-size: 13px; }

/* composer tools + popover */
.chat-tools-wrap { position: relative; }
.chat-tools { display: flex; gap: 6px; padding: 6px 12px 0; background: var(--surface); border-top: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.chat-tools::-webkit-scrollbar { display: none; }
.chat-tools .btn { flex-shrink: 0; }
.chat-tools .btn.on { border-color: var(--accent); color: var(--accent); }
.chat-tools-wrap + .composer { border-top: none; }
.tool-pop {
  position: absolute; left: 12px; right: 12px; bottom: calc(100% + 6px); z-index: 30; max-height: min(360px, 55vh); overflow-y: auto;
  padding: 6px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow);
}
.pop-head { font: 700 11px var(--fh); color: var(--dim); text-transform: uppercase; letter-spacing: .5px; padding: 6px 8px; }
.pop-note { padding: 2px 8px 8px; font-size: 12px; }
.pop-row { display: flex; gap: 4px; align-items: stretch; }
.pop-item {
  flex: 1; min-width: 0; text-align: left; padding: 8px 10px; background: none; border: none; border-radius: 6px;
  color: var(--text); font-size: 13px; line-height: 1.4; cursor: pointer; white-space: pre-wrap; overflow-wrap: anywhere;
}
.pop-item:hover, .tpl-card:hover:not(:disabled) { background: #2e2a20; }
.pop-del { flex-shrink: 0; width: 30px; background: none; border: none; border-radius: 6px; color: var(--dimmer); cursor: pointer; }
.pop-del:hover { color: var(--red); background: #2a1a14; }
.pop-foot { padding: 6px 4px 2px; border-top: 1px solid var(--border); margin-top: 4px; }
.tpl-grid { display: grid; gap: 4px; }
.tpl-card {
  flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: baseline; text-align: left;
  padding: 9px 11px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); color: var(--text); cursor: pointer;
}
.tpl-card b { font-family: var(--fh); font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-price { font-family: var(--fh); font-weight: 700; color: var(--accent); }
.tpl-card small { grid-column: 1 / -1; }
.tpl-card:disabled { opacity: .5; cursor: not-allowed; }

.chat-note { font-size: 12px; padding: 8px 16px; background: #17150f; color: #d8c79f; border-top: 1px solid #3a3220; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; background: var(--surface); border-top: 1px solid var(--border); }
.composer textarea.fi { min-height: 40px; max-height: 140px; resize: none; padding: 9px 13px; }
.composer .btn { height: 40px; flex-shrink: 0; }
.icon-btn { padding: 7px 11px; font-size: 16px; }

.pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.pick-row {
  display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r);
  cursor: pointer;
}
.pick-row:has(input:checked) { border-color: var(--accent); background: #1f1c14; }
.pick-row input { accent-color: var(--accent); }
.pick-row span { display: flex; flex-direction: column; min-width: 0; }
.pick-row small { color: var(--dim); font-size: 11px; }

/* ── Mobile: sidebar becomes a bottom sheet ── */
@media (max-width: 768px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .logo { font-size: 17px; }
  .topbar-actions .btn { padding: 6px 10px; font-size: 12px; min-width: 40px; }
  .uname, .topbar-actions .lbl, .back-link { display: none; }
  .topbar-actions { gap: 6px; }
  .user-badge { padding: 3px; }
  .user-badge .avatar { width: 34px; height: 34px; }
  @media (max-width: 420px) { /* up to 5 tap targets (admin) + logo must fit 375px */
    .user-badge { display: none; }
    .topbar { gap: 6px; padding: 0 8px; }
    .logo { font-size: 15px; }
    .topbar-actions { gap: 4px; }
    .topbar-actions .btn { min-width: 38px; padding: 6px 8px; }
  }
  /* touch: every tappable control at least 40px high */
  .btn, .btn-sm, .filter-btn, .seg button, .fi { min-height: 40px; }
  .btn { min-width: 40px; }
  .leaflet-touch .leaflet-bar a { width: 40px; height: 40px; line-height: 40px; }
  .logo { padding: 10px 0; }
  /* dashboard job card: price + "Presupuestos" become one row under the title */
  .job-side { width: 100%; display: flex; justify-content: space-between; align-items: center; }
  .job-side .btn { margin-top: 0; }
  .composer textarea.fi { min-height: 40px; }
  .detail-close { width: 40px; height: 40px; top: 6px; right: 6px; }
  .site-foot a { min-height: 40px; display: inline-flex; align-items: center; }

  /* filter pills move into their own scrollable strip below the topbar */
  .filters-wrap {
    position: absolute; top: var(--topbar-h); left: 0; right: 0; padding: 8px 12px;
    background: linear-gradient(var(--bg), transparent);
  }
  .leaflet-top.leaflet-right { top: 58px; } /* zoom under the category strip */

  /* cookie banner: full width at the bottom, with a margin; the sheet footer keeps room above it */
  .cookie-banner {
    left: 8px; right: 8px; width: auto; bottom: calc(8px + env(safe-area-inset-bottom));
    padding: 10px 12px; font-size: 12px; line-height: 1.45;
  }
  .cookie-actions { margin-top: 8px; flex-wrap: nowrap; gap: 6px; }
  .cookie-actions .btn { flex: 1 1 0; min-width: 0; padding: 6px 6px; font-size: 12px; white-space: normal; }
  /* the sheet's peek (tabs + counter) sits above the banner instead of under it */
  .sidebar[data-state="peek"] { transform: translateY(calc(100% - var(--peek, 130px) - var(--cookie-h, 0px))); }
  .sidebar .site-foot, .chat-list .site-foot { padding-bottom: calc(6px + var(--cookie-h, 0px)); }

  .sidebar {
    position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: 85%;
    border-right: none; border-top: 1px solid var(--border); border-radius: 16px 16px 0 0;
    transform: translateY(calc(100% - var(--peek, 130px)));
    transition: transform .28s cubic-bezier(.2,.8,.2,1); box-shadow: 0 -8px 30px rgba(0,0,0,.5);
    touch-action: none;
  }
  .sidebar.dragging { transition: none; }
  .sidebar[data-state="half"] { transform: translateY(50%); }
  .sidebar[data-state="full"] { transform: translateY(0); }
  .sheet-handle {
    display: block; width: 100%; height: 22px; background: none; border: none; cursor: grab; flex-shrink: 0;
    position: relative;
  }
  .sheet-handle::after {
    content: ""; position: absolute; left: 50%; top: 8px; width: 40px; height: 4px; margin-left: -20px;
    background: var(--dimmer); border-radius: 2px;
  }
  .sidebar-head { padding-top: 2px; touch-action: none; }
  .jobs-list { touch-action: pan-y; }

  .detail { left: 10px; right: 10px; width: auto; bottom: max(140px, var(--cookie-h, 0px)); max-height: 60%; }
  .form-row, .grid2 { grid-template-columns: 1fr; }
  .modal { padding: 22px; }
  .leaflet-bottom.leaflet-right { bottom: 130px; } /* attribution above the sheet */
}

/* ── Mobile messenger: list and chat are two screens ── */
@media (max-width: 768px) {
  .chat-list { width: 100%; border-right: none; }
  .chat-pane { display: none; }
  .chat-layout.show-chat .chat-list { display: none; }
  .chat-layout.show-chat .chat-pane { display: flex; }
  .chat-back { display: inline-flex; }
  .chat-head { padding: 8px 10px; gap: 8px; }
  .chat-msgs { padding: 12px 10px; }
  .msg { max-width: 88%; }
  .deal-bar { padding: 8px 10px; gap: 8px; }
  .deal-status { flex-basis: 100%; }
  .deal-actions { width: 100%; }
  .deal-actions .btn { flex: 1 1 auto; }
  .deal-main { min-height: 48px; }
  .deal-hint { padding: 8px 10px; }
  .composer { padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}

/* ── «Confirma tu email» banner (auth.js): floats under the topbar, never pushes the full-screen map ── */
.verify-banner {
  position: fixed; top: calc(var(--topbar-h) + 8px); left: 50%; transform: translateX(-50%); z-index: 1150;
  width: min(720px, calc(100vw - 32px)); display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--r);
  padding: 10px 12px; box-shadow: var(--shadow); font-size: 13px; line-height: 1.45;
}
.verify-banner span { flex: 1; }
.verify-banner .btn { flex-shrink: 0; }
@media (max-width: 768px) {
  .verify-banner { top: calc(var(--topbar-h) + 6px); font-size: 12px; padding: 8px 10px; gap: 8px; }
}

/* ── verificar.html / restablecer.html: result of the email link ── */
.verify-box { max-width: 460px; margin: 48px auto; text-align: center; }
.verify-box .empty-icon { font-size: 44px; margin-bottom: 8px; }
.verify-box .row { justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.verify-box form { text-align: left; margin-top: 16px; }
