:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede5;
  --text: #1c1a17;
  --muted: #6b665c;
  --border: #e2ddd1;
  --accent: #b8891f;
  --accent-ink: #1c1a17;
  --accent-soft: #f6ecd2;
  --danger: #b3261e;
  --warn: #b45309;
  --ok: #2e7d32;
  --radius: 12px;
  --nav-w: 220px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141310; --surface: #1e1c18; --surface-2: #27241f; --text: #f1ede4; --muted: #a39d90;
    --border: #36322b; --accent: #d4a63a; --accent-soft: #3a3020; --danger: #f2867e; --warn: #f0a85a; --ok: #7cc47f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141310; --surface: #1e1c18; --surface-2: #27241f; --text: #f1ede4; --muted: #a39d90;
  --border: #36322b; --accent: #d4a63a; --accent-soft: #3a3020; --danger: #f2867e; --warn: #f0a85a; --ok: #7cc47f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.5rem; }
button, input, select, textarea { font: inherit; color: inherit; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.warn { color: var(--warn); }
.error { color: var(--danger); margin: .5rem 0; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* Botones */
.btn {
  border: 1px solid var(--border); background: var(--surface); padding: .55rem 1rem;
  border-radius: 10px; cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: .3rem .7rem; font-size: .82rem; }
.icon-btn { border: 0; background: none; cursor: pointer; font-size: 1.1rem; padding: .3rem .5rem; color: var(--muted); }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.nav {
  width: var(--nav-w); flex: none; position: sticky; top: 0; height: 100vh;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px; padding: 16px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 4px 10px 16px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: .6rem .75rem; border-radius: 10px;
  text-decoration: none; color: var(--text);
}
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--accent-soft); font-weight: 600; }
.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.content { flex: 1; min-width: 0; padding: 28px 32px 48px; max-width: 1200px; }
.banner {
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: .6rem .9rem; margin-bottom: 18px; font-size: .88rem;
}

@media (max-width: 760px) {
  .shell { display: block; }
  .nav {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; width: auto; height: auto; z-index: 20;
    flex-direction: row; justify-content: space-around; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border);
  }
  .brand, .nav-foot { display: none; }
  .nav a { flex-direction: column; gap: 0; padding: 6px 2px; flex: 1; font-size: .68rem; text-align: center; }
  .nav-icon { font-size: 1.2rem; }
  .content { padding: 16px 16px 96px; }
}

/* Encabezado y métricas */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-value { font-size: 1.45rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.stats > .wide-note { grid-column: 1 / -1; margin: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; overflow-x: auto; max-width: 100%; }
.segmented button { border: 0; background: none; padding: .35rem .75rem; border-radius: 8px; cursor: pointer; white-space: nowrap; font-size: .88rem; }
.segmented button.on { background: var(--surface); box-shadow: 0 1px 2px rgb(0 0 0 / .12); font-weight: 600; }
.search {
  flex: 1; min-width: 180px; padding: .5rem .75rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
}

/* Tarjetas de propiedades */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 10px;
}
.card:hover { border-color: var(--accent); }
.prop-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.prop-top h3 { font-size: 1rem; }
.status { font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; background: var(--surface-2); }
.s-disponible { color: var(--ok); }
.s-reservada { color: var(--warn); }
.s-cerrada { color: var(--accent); }
.s-retirada { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .74rem; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--border); color: var(--muted); }
.chip.accent { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 0; }
.kv dt { font-size: .74rem; color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.prop-foot { display: flex; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 8px; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty-icon { font-size: 2.4rem; }
.empty h2 { color: var(--text); margin: 8px 0; }

/* Modal y formularios */
.overlay {
  position: fixed; inset: 0; background: rgb(0 0 0 / .45); z-index: 50;
  display: grid; place-items: center; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: 16px; width: min(640px, 100%); max-height: calc(100vh - 32px);
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgb(0 0 0 / .3);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 1.1rem; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }
.spacer { flex: 1; }
@media (max-width: 760px) {
  .overlay { padding: 0; place-items: end stretch; }
  .modal { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.grid-form .wide { grid-column: 1 / -1; }
@media (max-width: 520px) { .grid-form { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus, .search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field.check { flex-direction: row; align-items: center; gap: 8px; align-self: end; padding-bottom: .5rem; }
.field.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.req { color: var(--danger); }
.hint { color: var(--muted); font-size: .75rem; }
.section-title { font-size: .9rem; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.calc-preview {
  display: flex; flex-wrap: wrap; gap: 6px 20px; background: var(--accent-soft); border-radius: 10px;
  padding: .6rem .8rem; font-size: .88rem;
}

/* Clientes y contactos */
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 520px) { .page-head { flex-wrap: wrap; } .head-actions { width: 100%; justify-content: stretch; } .head-actions .btn { flex: 1; padding-inline: .5rem; } }
.goal-stats { grid-template-columns: minmax(160px, 1fr) minmax(220px, 2fr); }
@media (max-width: 520px) { .goal-stats { grid-template-columns: 1fr; } }
.of { font-size: 1rem; color: var(--muted); font-weight: 500; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar span.done { background: var(--ok); }
.stat-sub.ok { color: var(--ok); }
.stat-sub.warn { color: var(--warn); }
.ok-banner { display: flex; justify-content: space-between; align-items: center; border-color: var(--ok); }

.grp {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; flex: none;
  font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--muted);
}
.grp.g-A { background: var(--accent); color: var(--accent-ink); }
.grp.g-B { background: var(--accent-soft); color: var(--text); }
.picked .grp, .picker-list .grp { width: 20px; height: 20px; font-size: .7rem; vertical-align: middle; }

.client-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.client-row { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); padding-right: 10px; }
.client-row:last-child { border-bottom: 0; }
.client-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0; background: none; text-align: left; cursor: pointer; }
.client-main:hover { background: var(--surface-2); }
.client-name { flex: 1; min-width: 0; display: flex; flex-direction: column; font-weight: 600; overflow: hidden; }
.client-name, .client-name span { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.client-name span { font-weight: 400; }
.client-last { white-space: nowrap; }
.client-actions { display: flex; gap: 6px; flex: none; }
a.btn { text-decoration: none; display: inline-block; }
@media (max-width: 520px) { .client-actions a { display: none; } .client-last { display: none; } }
.more { text-align: center; margin-top: 12px; }

.history { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.history-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.history-head h3 { font-size: .95rem; }
.log { list-style: none; margin: 0; padding: 0; }
.card-log { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.log li { border-bottom: 1px solid var(--border); }
.log li:last-child { border-bottom: 0; }
.log-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; background: none; text-align: left; cursor: pointer; }
.log-row:hover { background: var(--surface-2); }
.log-date { font-size: .8rem; color: var(--muted); white-space: nowrap; width: 112px; flex: none; }
@media (max-width: 520px) { .log-date { width: auto; white-space: normal; max-width: 70px; } }
.log-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.log-main .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.picker { position: relative; }
.picker input { width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.picker-list { list-style: none; margin: 4px 0 0; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); max-height: 260px; overflow-y: auto; }
.picker-list button { width: 100%; text-align: left; border: 0; background: none; padding: .45rem .6rem; border-radius: 8px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.picker-list button:hover { background: var(--surface-2); }
.picked { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: .45rem .7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.import-summary { background: var(--surface-2); border-radius: 10px; padding: .6rem 1rem; margin-top: 12px; }
.import-summary p { margin: 0 0 4px; }
.import-summary ul { margin: 0; padding-left: 1.1rem; }

/* ACM y cierres */
.alert {
  border: 1px solid var(--warn); background: var(--surface); border-radius: var(--radius);
  padding: .7rem 1rem; margin-bottom: 16px; font-size: .9rem;
}
.alert ul { margin: 6px 0 0; padding-left: 1.1rem; }
.linklike { border: 0; background: none; padding: 2px 0; color: var(--text); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; text-align: left; }
.s-acm-enviado, .s-acm-pendiente { color: var(--muted); }
.s-acm-recontactar { color: var(--warn); }
.s-acm-captado { color: var(--ok); }
.s-acm-rechazado { color: var(--danger); }
.amount { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.log-date.warn { color: var(--warn); font-weight: 600; }
.calc-preview:not(.wide) { align-self: end; }

/* Tablero */
.block-title { font-size: 1.05rem; margin: 4px 0 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.month-select { padding: .45rem .7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.goals-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.bar.marked { position: relative; overflow: visible; }
.bar.marked span { position: relative; }
.bar.marked i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); border-radius: 1px; transform: translateX(-1px); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; }
.panel h2 { font-size: 1rem; margin-bottom: 12px; }
.panel p { margin: 10px 0 0; }
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 190px 1fr 50px 130px; gap: 12px; align-items: center; }
.funnel-label { font-size: .88rem; }
.funnel-bar { height: 22px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.funnel-bar span { display: block; height: 100%; background: var(--accent); }
.funnel-n { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.funnel-rate { display: flex; flex-direction: column; font-size: .9rem; }
.funnel-rate .ok, td.ok { color: var(--ok); }
.funnel-rate .warn, td.warn { color: var(--warn); }
@media (max-width: 620px) {
  .funnel-row { grid-template-columns: 1fr auto; grid-template-areas: "label n" "bar bar" "rate rate"; gap: 4px 10px; }
  .funnel-label { grid-area: label; } .funnel-n { grid-area: n; } .funnel-bar { grid-area: bar; } .funnel-rate { grid-area: rate; flex-direction: row; gap: 8px; }
}
.mini-list { list-style: none; margin: 6px 0 0; padding: 0; font-size: .88rem; }
.mini-list li { display: flex; justify-content: space-between; padding: 2px 0; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table th { text-align: right; font-size: .75rem; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.table td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--border); }
.table th:first-child, .table td:first-child { text-align: left; }
.table tr:last-child td { border-bottom: 0; }

/* Seguimiento de propiedades */
.prop-card { padding: 0; gap: 0; cursor: default; overflow: hidden; }
.prop-main { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 0; background: none; text-align: left; cursor: pointer; width: 100%; }
.prop-main:hover { background: var(--surface-2); }
.track-btn {
  display: flex; justify-content: space-between; gap: 8px; width: 100%; padding: 9px 16px;
  border: 0; border-top: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-size: .82rem; font-weight: 600;
}
.track-btn span:last-child { font-weight: 400; color: var(--muted); }
.track-btn.due { background: var(--accent-soft); }
.track-btn.due span:last-child { color: var(--warn); font-weight: 600; }
.track-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: .85rem; margin-bottom: 12px; }
.mini-charts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.mini-chart { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.mini-chart-head { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin-bottom: 4px; }
.mini-chart-head strong { color: var(--text); font-size: .95rem; }
.mini-chart svg { width: 100%; height: 48px; display: block; }
.mini-chart rect { fill: var(--accent); }
.modal-body .calc-preview { margin-bottom: 10px; }
.prev-totals { background: var(--surface-2); border-radius: 8px; padding: .45rem .7rem; margin: 0 0 12px; }
.chart-note { margin: -4px 0 12px; }

/* Agenda */
.gcal-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.ok-text { color: var(--ok); }
.week-nav { gap: 6px; }
.week-nav strong { min-width: 190px; text-align: center; }
.pending-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-bottom: 16px; }
.pending-grid .alert { margin: 0; }
.pending-grid .alert p { margin: 4px 0 8px; }
.week { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 1100px) { .week { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; } }
.day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.day.today { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.day-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.ev { font-size: .82rem; border-left: 3px solid var(--border); background: var(--surface-2); border-radius: 0 6px 6px 0; padding: 4px 7px; overflow-wrap: anywhere; }
.ev a, .ev .linklike { color: var(--text); text-decoration: none; display: block; font-size: inherit; text-align: left; }
.ev.c21 { border-left-color: #f6bf26; background: color-mix(in srgb, #f6bf26 16%, var(--surface)); }
.ev-time { display: block; font-size: .72rem; color: var(--muted); font-weight: 600; }
.task { display: flex; align-items: flex-start; justify-content: space-between; gap: 4px; font-size: .85rem; }
.task label { display: flex; gap: 6px; align-items: flex-start; cursor: pointer; overflow-wrap: anywhere; }
.task input { margin-top: 3px; accent-color: var(--accent); }
.task.done span { text-decoration: line-through; color: var(--muted); }
.icon-btn.small { font-size: .8rem; padding: 0 4px; }
.add-task input { width: 100%; padding: .35rem .5rem; border: 1px dashed var(--border); border-radius: 8px; background: transparent; font-size: .82rem; }
.add-task input:focus { outline: 2px solid var(--accent); border-style: solid; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px; display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.login-card img { margin: 0 auto; border-radius: 12px; }
.login-card .field { text-align: left; }

/* ───────── Chat del asistente ───────── */
.chat-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 40;
  display: flex; align-items: center; gap: 8px; padding: .75rem 1.1rem; border-radius: 99px;
  border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 20px rgb(0 0 0 / .18); font-size: 1rem;
}
.chat-fab span[aria-hidden] { font-size: 1.25rem; line-height: 1; }
.chat-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 45;
  width: min(420px, calc(100vw - 40px)); height: min(640px, calc(100vh - 40px));
  display: flex; flex-direction: column; background: var(--bg);
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  box-shadow: 0 12px 40px rgb(0 0 0 / .22);
}
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.chat-head .spacer { flex: 1; }
.chat-list { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.chat-empty { margin: auto 0; display: flex; flex-direction: column; gap: 6px; }
.chat-empty p { margin: 0; }
.chat-examples { margin: 0 0 6px; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.chat-examples .linklike { text-align: left; }
.msg { display: flex; flex-direction: column; gap: 6px; max-width: 88%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; }
.bubble { padding: .55rem .85rem; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.assistant .bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.typing { display: flex; gap: 4px; padding: .75rem .9rem; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.action-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; min-width: min(300px, 100%); }
.action-card.pending { border: 2px solid var(--accent); }
.action-title { font-weight: 700; margin-bottom: 8px; }
.action-card dl { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.action-card dl div { display: grid; grid-template-columns: 110px 1fr; gap: 8px; font-size: .9rem; }
.action-card dt { color: var(--muted); }
.action-card dd { margin: 0; overflow-wrap: anywhere; }
.action-warn { color: var(--warn); font-size: .85rem; margin: 8px 0 0; }
.action-buttons { display: flex; gap: 8px; margin-top: 12px; }
.action-buttons .btn { flex: 1; padding-block: .7rem; }
.action-status { margin-top: 10px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.action-status.confirmed { color: var(--ok); }
.action-status.error { color: var(--danger); }

.chat-error, .chat-note { margin: 0; padding: 6px 14px; }
.chat-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px; background: var(--surface); border-top: 1px solid var(--border); }
.chat-compose textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 140px; padding: .6rem .8rem;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg); font-size: 16px;
}
.chat-compose textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.mic, .chat-compose .send { width: 44px; height: 44px; flex: none; border-radius: 50%; padding: 0; display: grid; place-items: center; font-size: 1.1rem; }
.mic { border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.mic.on { background: var(--danger); color: #fff; border-color: var(--danger); animation: pulse 1.2s infinite; }
.chat-compose .attach { width: 40px; height: 44px; flex: none; border: none; background: none; font-size: 1.25rem; cursor: pointer; padding: 0; }
.chat-attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px 0; background: var(--surface); border-top: 1px solid var(--border); }
.chat-attachments + .chat-compose { border-top: none; }
.att-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 220px; padding: 3px 4px 3px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: .8rem; background: var(--bg); }
.att-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bubble .att-line { display: block; margin-top: 4px; font-size: .85em; opacity: .85; }

/* Archivos de un ACM / propiedad */
.files-panel { display: grid; gap: 8px; }
.fill-sheet { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.fill-sheet .hint { flex-basis: 100%; }
.c21-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.c21-list > li { border: 1px solid var(--line, #e5e0d8); border-radius: 10px; padding: 10px 12px; }
.c21-cands { display: grid; gap: 6px; margin-top: 6px; }
.c21-cand, .c21-head { display: flex; gap: 8px; align-items: flex-start; font-size: .9rem; }
.c21-fields { display: grid; gap: 4px; margin: 8px 0 0; font-size: .85rem; }
.c21-fields > div { display: grid; grid-template-columns: 110px 1fr; gap: 8px; }
.c21-fields dt { color: var(--muted); }
.c21-fields dd { margin: 0; overflow-wrap: anywhere; }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.file-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.file-list .file-name { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(179 38 30 / .5); } 70% { box-shadow: 0 0 0 10px rgb(179 38 30 / 0); } 100% { box-shadow: 0 0 0 0 rgb(179 38 30 / 0); } }

@media (max-width: 760px) {
  .chat-fab { right: 14px; bottom: calc(72px + env(safe-area-inset-bottom)); padding: .8rem; }
  .chat-fab-label { display: none; }
  .chat-fab span[aria-hidden] { font-size: 1.5rem; }
  .chat-panel { inset: 0; width: auto; height: auto; border-radius: 0; border: 0; z-index: 60; }
  .chat-head { padding-top: calc(10px + env(safe-area-inset-top)); }
  .chat-compose { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
}

/* Lugar para el cartel "Powered by Netlify" (abajo a la derecha) */
.host-badge .chat-fab { bottom: 84px; }
.host-badge .chat-panel { bottom: 84px; height: min(640px, calc(100vh - 104px)); }
@media (max-width: 760px) {
  .host-badge .chat-panel { bottom: 0; height: auto; }
  .host-badge .chat-compose { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .host-badge .chat-fab { bottom: calc(136px + env(safe-area-inset-bottom)); }
  .host-badge .nav { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .host-badge .content { padding-bottom: 150px; }
}
