/* =====================================================================
   TEMA VISUAL — InmoERP
   Capa de estilo inspirada en Bootstrap 5: tipografía, espaciados,
   controles y sombras con el mismo lenguaje visual en todo el sistema.
   Se carga DESPUÉS de app.css y ANTES de los colores configurables,
   de modo que la paleta elegida en Apariencia sigue mandando.
   Sólo cambia la apariencia: no se toca ninguna clase ni estructura.
   ===================================================================== */

:root {
  /* Grises de Bootstrap 5 */
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --surface-3: #eef1f5;
  --border: #e4e7ec;
  --border-strong: #ced4da;
  --text-2: #495057;
  --muted: #6c757d;

  /* Sombras discretas, al estilo de Bootstrap */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18), 0 4px 8px -4px rgba(16, 24, 40, .06);

  /* Radio de los controles: proporcional al que se elija en Apariencia */
  --radius-ctl: clamp(4px, calc(var(--radius, 14px) * .5), 10px);
  --radius-pill: 50rem;

  /* Alturas únicas para que todo quede alineado en las barras de filtros */
  --h-control: 40px;
  --h-control-sm: 33px;
  --h-topbar: 64px;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --focus-ring: 0 0 0 .2rem color-mix(in srgb, var(--primary) 25%, transparent);
}

:root[data-theme="dark"], :root.auto-dark {
  --surface: #161b25;
  --surface-2: #1b212c;
  --surface-3: #232b38;
  --border: #2a323f;
  --border-strong: #3a4454;
  --text-2: #c9d2e0;
  --muted: #8b95a7;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 1px 3px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, .7), 0 4px 10px -4px rgba(0, 0, 0, .5);
}

/* ---------------------------- Tipografía ---------------------------- */
body { font-family: var(--font); font-size: .9375rem; line-height: 1.5; -webkit-font-smoothing: antialiased; letter-spacing: 0; }
h1, h2, h3, h4, h5 { font-weight: 600; letter-spacing: -.011em; line-height: 1.3; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
small, .small { font-size: .8125rem; }
b, strong { font-weight: 600; }
a { color: var(--link, var(--primary)); text-underline-offset: 2px; }

/* ------------------------------ Barra lateral ------------------------ */
.sidebar { background: var(--sidebar); border-right: 1px solid color-mix(in srgb, #fff 8%, transparent); }
.brand { padding: 0 1rem; height: var(--h-topbar); border-bottom: 1px solid color-mix(in srgb, #fff 9%, transparent); gap: .7rem; }
.brand .logo { width: 36px; height: 36px; border-radius: var(--radius-ctl); background: var(--primary); box-shadow: none; font-size: 1rem; }
.brand b { font-size: .95rem; font-weight: 600; letter-spacing: -.01em; }
.brand small { font-size: .72rem; opacity: .75; }
.brand-logo { height: 36px; max-width: 92px; border-radius: var(--radius-ctl); }

.menu { padding: .75rem .625rem 1.25rem; }
.menu-group { margin-top: 1.1rem; }
.menu-group:first-child { margin-top: .25rem; }
.menu-group > span { padding: .25rem .75rem .45rem; font-size: .66rem; letter-spacing: .1em; opacity: .55; font-weight: 700; }
.menu a { padding: .5rem .75rem; border-radius: var(--radius-ctl); font-size: .875rem; font-weight: 500; gap: .65rem; margin-bottom: 1px; }
.menu a i { font-size: 1rem; width: 18px; opacity: .8; }
.menu a:hover { background: color-mix(in srgb, #fff 8%, transparent); color: #fff; }
.menu a.active { background: var(--primary); color: var(--btn-text, #fff); box-shadow: none; font-weight: 600; }
.menu a.active i { opacity: 1; }
.sidebar-foot { padding: .75rem 1rem; font-size: .72rem; opacity: .55; border-top: 1px solid color-mix(in srgb, #fff 8%, transparent); }

/* ------------------------------ Barra superior ----------------------- */
.topbar { height: var(--h-topbar); padding: 0 1.25rem; gap: .75rem; background: var(--topbar, var(--surface)); backdrop-filter: none; border-bottom: 1px solid var(--border); box-shadow: none; }
.icon-btn { width: 36px; height: 36px; border-radius: var(--radius-ctl); color: var(--muted); font-size: 1.05rem; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .dot { background: var(--danger); border-width: 2px; border-color: var(--topbar, var(--surface)); font-size: .64rem; }
.global-search input { height: var(--h-control); border-radius: var(--radius-pill); background: var(--surface-2); border-color: var(--border); font-size: .875rem; padding-left: 2.5rem; }
.global-search input:focus { box-shadow: var(--focus-ring); background: var(--surface); }
.global-search > i { left: .95rem; font-size: .9rem; }
.user-chip { border-radius: var(--radius-pill); padding: .2rem .6rem .2rem .2rem; gap: .5rem; }
.avatar { width: 34px; height: 34px; border-radius: var(--radius-pill); background: var(--primary); color: var(--btn-text, #fff); font-size: .78rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.15rem; }
.avatar.teal { background: var(--accent); }
.user-chip .who b { font-size: .82rem; font-weight: 600; }
.user-chip .who small { font-size: .7rem; }

/* ------------------------------ Contenido ---------------------------- */
.content { padding: 1.5rem 1.75rem 3.5rem; }
.crumbs { font-size: .78rem; margin-bottom: .5rem; gap: .4rem; }
.page-head { margin-bottom: 1.35rem; align-items: center; }
.page-head h1 { font-size: 1.4rem; gap: .65rem; }
.page-head h1 .h-icon { width: 40px; height: 40px; border-radius: var(--radius-ctl); background: var(--primary-50); color: var(--primary); font-size: 1.05rem; }
.page-head p { font-size: .875rem; margin-top: .3rem; max-width: 78ch; }

/* ------------------------------ Tarjetas ----------------------------- */
.card { border-radius: var(--radius); box-shadow: var(--shadow-sm); border-color: var(--border); }
.card + .card { margin-top: 1.25rem; }
/* En una rejilla las tarjetas van lado a lado: la separación la da el "gap", no el margen superior */
.grid > .card + .card, .grid > .card ~ .card, .kpis > .card + .card { margin-top: 0; }
.card-head { padding: .9rem 1.25rem; background: transparent; }
.card-head h2, .card-head h3 { font-size: .975rem; font-weight: 600; gap: .55rem; }
.card-head h2 i, .card-head h3 i { font-size: 1rem; }
.card-body { padding: 1.25rem; }
.card-foot { padding: .85rem 1.25rem; background: var(--surface-2); }
.grid { gap: 1.25rem; }

/* Indicadores */
.kpis { gap: 1rem; margin-bottom: 1.35rem; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }
.kpi { border-radius: var(--radius); padding: 1.05rem 1.15rem; gap: .9rem; box-shadow: var(--shadow-sm); transition: box-shadow .15s, border-color .15s; }
a.kpi:hover { transform: none; border-color: var(--primary); box-shadow: var(--shadow); }
.kpi .ki { width: 42px; height: 42px; border-radius: var(--radius-ctl); font-size: 1.15rem; }
.kpi .kl { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .kv { font-size: clamp(1.15rem, 1.6vw, 1.45rem); font-weight: 700; margin-top: .15rem; letter-spacing: -.02em; }
.kpi .kd { font-size: .74rem; font-weight: 500; margin-top: .2rem; }
.kpi-activo { border-color: var(--primary); box-shadow: var(--focus-ring); }

/* ------------------------------ Botones ------------------------------ */
.btn {
  height: var(--h-control); padding: 0 1rem; border-radius: var(--radius-ctl);
  font-size: .875rem; font-weight: 500; gap: .5rem; letter-spacing: 0;
  border-color: var(--border-strong); background: var(--surface); color: var(--text-2);
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn i { font-size: .95rem; }
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); }
.btn:active { transform: none; }
.btn:focus-visible { outline: 0; box-shadow: var(--focus-ring); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--btn-text, #fff); box-shadow: none; font-weight: 600; }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); color: var(--btn-text, #fff); }
.btn-success { color: #fff; font-weight: 600; }
.btn-success:hover { filter: brightness(1.05); }
.btn-danger { color: #fff; font-weight: 600; }
.btn-danger:hover { filter: brightness(1.05); }
.btn-outline-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: transparent; }
.btn-outline-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-soft { background: var(--primary-50); color: var(--primary); border-color: transparent; font-weight: 600; }
.btn-soft:hover { background: var(--primary-100); color: var(--primary); }
.btn-wa:hover { background: #1fb959; border-color: #1fb959; color: #fff; }
.btn-sm { height: var(--h-control-sm); padding: 0 .75rem; font-size: .8125rem; border-radius: var(--radius-ctl); }
.btn-sm i { font-size: .85rem; }
.btn-xs { height: 28px; padding: 0 .55rem; font-size: .75rem; border-radius: calc(var(--radius-ctl) - 1px); }
.btn-icon { width: var(--h-control-sm); height: var(--h-control-sm); padding: 0; }
.btn-group { gap: 0; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-ctl) 0 0 var(--radius-ctl); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-ctl) var(--radius-ctl) 0; }
.btn-group .btn:only-child { border-radius: var(--radius-ctl); }

/* ------------------------------ Formularios -------------------------- */
.form-grid { gap: 1rem 1.15rem; }
.field { gap: .4rem; }
.field > label, .lbl { font-size: .8125rem; font-weight: 600; color: var(--text-2); letter-spacing: 0; }
.input, select.input, textarea.input {
  height: var(--h-control); padding: .375rem .75rem; border-radius: var(--radius-ctl);
  border-color: var(--border-strong); font-size: .875rem; color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea.input { min-height: 92px; padding: .55rem .75rem; }
select.input { padding-right: 2.25rem; background-position: right .75rem center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='14' height='14'%3E%3Cpath fill='none' stroke='%236c757d' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E"); }
.input:focus { border-color: var(--primary); box-shadow: var(--focus-ring); }
.input:focus-visible { outline: 0; }
.input[readonly], .input:disabled { background: var(--surface-2); color: var(--muted); }
.input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--danger) 20%, transparent); }
.input-sm { height: var(--h-control-sm); font-size: .8125rem; padding: .2rem .6rem; }
.hint { font-size: .78rem; line-height: 1.4; }
.error { font-size: .78rem; }
.input-group .addon { border-radius: var(--radius-ctl) 0 0 var(--radius-ctl); font-size: .8125rem; }
.input-group .input { border-radius: 0 var(--radius-ctl) var(--radius-ctl) 0; }
.check { font-size: .875rem; gap: .45rem; }
.check input { width: 16px; height: 16px; border-radius: 4px; }
.switch { font-size: .875rem; }
.switch input { width: 36px; height: 20px; }
.switch input::after { width: 14px; height: 14px; }
.switch input:checked::after { left: 19px; }
.form-section {
  font-size: .7rem; letter-spacing: .09em; color: var(--muted);
  border-bottom: 1px solid var(--border); padding: 1rem 0 .5rem; margin-top: .35rem; gap: .45rem;
}
.form-section:first-child { padding-top: 0; margin-top: 0; }
.form-section i { color: var(--primary); font-size: .85rem; }
.form-actions { padding-top: 1.15rem; margin-top: 1.15rem; gap: .6rem; }

/* ------------------------------ Barra de filtros --------------------- */
.toolbar { padding: .85rem 1.25rem; gap: .55rem; align-items: center; }
.toolbar .search { min-width: 210px; max-width: 340px; }
.toolbar .search .input { height: var(--h-control-sm); padding-left: 2.15rem; border-radius: var(--radius-pill); }
.toolbar .search i { left: .8rem; font-size: .85rem; }
.toolbar select.input, .toolbar input.input { height: var(--h-control-sm); font-size: .8125rem; min-width: 148px; }
.toolbar .btn { height: var(--h-control-sm); font-size: .8125rem; }
.toolbar .check, .toolbar .lbl { font-size: .8125rem; }
.chip { border-radius: var(--radius-pill); font-size: .8125rem; padding: .3rem .75rem; font-weight: 500; }
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--btn-text, #fff); font-weight: 600; }
.chip.active .n { background: color-mix(in srgb, #fff 25%, transparent); color: inherit; }

/* ------------------------------ Tablas ------------------------------- */
.table { font-size: .875rem; }
.table th {
  font-size: .72rem; font-weight: 600; letter-spacing: .05em; color: var(--muted);
  padding: .7rem 1.1rem; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.table td { padding: .8rem 1.1rem; border-bottom: 1px solid var(--border); }
.table tbody tr:hover { background: var(--surface-2); }
.table.compact td, .table.compact th { padding: .5rem .8rem; }
.table tfoot td { background: var(--surface-2); font-weight: 600; }
.cell-title { font-weight: 600; }
.cell-sub { font-size: .78rem; line-height: 1.45; margin-top: .1rem; }
.table .actions .btn + .btn { margin-left: .2rem; }

.pager { padding: .85rem 1.25rem; font-size: .8125rem; }
.pager .pages { gap: .2rem; }
.pager .pages a, .pager .pages span { min-width: 34px; height: 34px; border-radius: var(--radius-ctl); font-weight: 500; font-size: .8125rem; }
.pager .pages a:hover { background: var(--surface-3); border-color: var(--border-strong); }
.pager .pages .cur { background: var(--primary); border-color: var(--primary); color: var(--btn-text, #fff); font-weight: 600; }

/* ------------------------------ Distintivos -------------------------- */
.badge { border-radius: var(--radius-pill); font-size: .72rem; font-weight: 600; padding: .22rem .65rem; letter-spacing: .01em; }
.badge::before { width: 5px; height: 5px; }
.tag { border-radius: var(--radius-ctl); font-size: .72rem; padding: .16rem .5rem; font-weight: 500; }

/* ------------------------------ Avisos ------------------------------- */
.alert { border-radius: var(--radius-ctl); padding: .85rem 1.05rem; font-size: .875rem; gap: .75rem; border-width: 1px; border-left-width: 4px; }
.alert i { font-size: 1.05rem; }
.alert .grow { line-height: 1.5; }

.empty { padding: 3.25rem 1rem; }
.empty .ei { width: 60px; height: 60px; border-radius: var(--radius); font-size: 1.6rem; margin-bottom: 1rem; }
.empty h3 { font-size: 1rem; margin-bottom: .35rem; }
.empty p { font-size: .875rem; max-width: 46ch; margin: 0 auto; }

/* ------------------------------ Pestañas ----------------------------- */
.tabs { padding: 0 1.25rem; gap: .35rem; }
.tabs a, .tabs button { padding: .85rem .75rem; font-size: .8625rem; font-weight: 500; border-bottom-width: 2px; }
.tabs a:hover, .tabs button:hover { color: var(--primary); }
.tabs .active { font-weight: 600; }
.tabs .cnt { border-radius: var(--radius-pill); font-size: .68rem; padding: .05rem .4rem; font-weight: 600; }
.tabs .active .cnt { background: var(--primary-50); color: var(--primary); }

/* ------------------------------ Listas de detalle -------------------- */
.dl { font-size: .875rem; gap: .65rem 1rem; }
.dl dt { font-size: .8125rem; font-weight: 500; }
.dl dd { font-weight: 500; }
.stat { border-radius: var(--radius-ctl); padding: .8rem .95rem; }
.stat .sl { font-size: .7rem; letter-spacing: .05em; }
.stat .sv { font-size: 1.15rem; font-weight: 700; margin-top: .15rem; }
.progress { height: 7px; background: var(--surface-3); }
.progress > span { background: var(--primary); }
.progress.green > span { background: var(--success); }
.progress.amber > span { background: var(--warning); }
.timeline .tl-i { border-radius: var(--radius-ctl); width: 30px; height: 30px; font-size: .85rem; }
.timeline::before { left: 14px; }
.timeline li { padding-left: 42px; padding-bottom: 1.2rem; }
.list-plain li { padding: .7rem 0; font-size: .875rem; }

/* ------------------------------ Menús y paneles ---------------------- */
.dropdown .dd-menu { border-radius: var(--radius-ctl); padding: .3rem; box-shadow: var(--shadow-lg); min-width: 226px; }
.dd-menu { max-width: calc(100vw - 16px); }
.dd-menu a, .dd-menu button { border-radius: calc(var(--radius-ctl) - 1px); font-size: .85rem; padding: .5rem .65rem; }
.search-results { border-radius: var(--radius-ctl); padding: .3rem; box-shadow: var(--shadow-lg); }
.search-results a { border-radius: calc(var(--radius-ctl) - 1px); font-size: .875rem; }
.notif-item { padding: .8rem 1.05rem; font-size: .875rem; }
.notif-item .ni { border-radius: var(--radius-ctl); }

/* ------------------------------ Ventanas modales --------------------- */
.modal { background: rgba(16, 24, 40, .5); padding: 3vh 1rem; }
.modal-dialog { border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.modal-head { padding: 1.05rem 1.35rem; }
.modal-head h3 { font-size: 1.02rem; font-weight: 600; }
.modal-body { padding: 1.35rem; }
.modal-foot, .modal .form-actions { border-radius: 0 0 var(--radius) var(--radius); padding: .95rem 1.35rem; }
.modal .form-actions { margin: 1.35rem -1.35rem -1.35rem; }
.spinner { border-width: 2.5px; }

.toast { border-radius: var(--radius-ctl); font-size: .875rem; padding: .85rem 1rem; }

/* ------------------------------ Tablero comercial -------------------- */
.kcol { border-radius: var(--radius); background: var(--surface-2); }
.kcol-h { font-size: .8125rem; font-weight: 600; padding: .8rem .9rem; }
.kcard { border-radius: var(--radius-ctl); padding: .75rem .85rem; font-size: .8375rem; box-shadow: none; }
.kcard:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }

/* ------------------------------ Calendario --------------------------- */
.cal .dow { font-size: .7rem; letter-spacing: .05em; padding: .6rem; }
.cal .day { min-height: 116px; padding: .4rem; }
.cal .ev { border-radius: 4px; font-size: .71rem; padding: .18rem .4rem; font-weight: 500; }
.cal-semana .ch { font-size: .8rem; }
.ag-item { border-radius: var(--radius-ctl); }

/* ------------------------------ Otros -------------------------------- */
.segmented { border-radius: var(--radius-ctl); overflow: hidden; }
.segmented a { padding: .45rem .8rem; font-size: .8125rem; font-weight: 500; }
.segmented a.active { font-weight: 600; }
.toolbar .segmented { height: var(--h-control-sm); }
.toolbar .segmented a { padding-top: 0; padding-bottom: 0; }
.section-title { font-size: .72rem; letter-spacing: .07em; color: var(--muted); margin: 1.35rem 0 .7rem; }
.plano-tools { border-radius: var(--radius-ctl); }
.plano-stage, .doc-stage, .mapa-caja { border-radius: var(--radius); }
.img-card, .img-thumb.xs { border-radius: var(--radius-ctl); }
.img-thumb { border-radius: 0; }
.img-meta b { font-size: .875rem; }
.contact-row, .clause-edit, .dup-box { border-radius: var(--radius-ctl); }
.check-list li { border-radius: var(--radius-ctl); }
.brand-preview { border-radius: var(--radius); }
.sticky-summary { top: calc(var(--h-topbar) + 1rem); }
.table-wrap { border-radius: 0 0 var(--radius) var(--radius); }
.ubi .input { padding-left: 2.35rem; }
.ubi > .bi-geo-alt { left: .8rem; }

/* Barras de desplazamiento discretas */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; border: 3px solid transparent; }

/* ------------------------------ Inicio de sesión --------------------- */
.auth-art { padding: 3.5rem; }
.auth-art h1 { font-size: 2.1rem; font-weight: 700; letter-spacing: -.02em; }
.auth-art p { font-size: .975rem; }
.auth-feats div { border-radius: var(--radius-ctl); font-size: .85rem; }
.auth-box h2 { font-size: 1.5rem; font-weight: 700; }
.auth-box .input { height: 46px; }
.auth-box .btn { height: 46px; font-size: .9375rem; font-weight: 600; }
.portal-top { background: var(--sidebar); }
.portal-nav a { font-size: .8625rem; font-weight: 500; }

/* ------------------------------ Móvil -------------------------------- */
@media (max-width: 720px) {
  .content { padding: 1rem .9rem 3rem; }
  .page-head h1 { font-size: 1.2rem; }
  .card-body, .toolbar { padding: 1rem; }
  .modal-body { padding: 1.1rem; }
  .modal .form-actions { margin: 1.1rem -1.1rem -1.1rem; padding: .85rem 1.1rem; }
  table.table.como-fichas tr { border-radius: var(--radius-ctl); }
}

/* ------------------------------ Correcciones de alineación ----------- */
/* Un elemento marcado como oculto debe estarlo aunque su clase defina display */
[hidden] { display: none !important; }

/* Los campos de una barra de filtros se reparten el ancho y siempre quedan alineados */
.toolbar > .search { flex: 1 1 210px; max-width: 340px; }
.toolbar > select.input, .toolbar > input.input { flex: 0 1 auto; max-width: 260px; }
.toolbar .ubi-filtro { flex: 1 1 210px; max-width: 320px; min-width: 190px; }
.toolbar .ubi { flex: 1; width: 100%; }
.ubi .input, .toolbar .ubi .input { width: 100%; flex: 1 1 auto; min-width: 0; }
.toolbar .search .input, .search .input { width: 100%; }
.ubi-clear { top: 50%; transform: translateY(-50%); width: 26px; height: 26px; }
.toolbar > form { display: contents; }

/* Las acciones de la cabecera y de las tarjetas comparten la misma altura */
.page-actions .btn { height: var(--h-control); }
.card-head .btn, .card-head .badge { align-self: center; }

/* Las reglas del móvil van al final para que tengan la última palabra */
@media (max-width: 720px) {
  /* En el celular cada filtro ocupa todo el ancho: quedan perfectamente alineados */
  .toolbar { gap: .5rem; }
  .toolbar > .search, .toolbar > select.input, .toolbar > input.input, .toolbar .ubi-filtro,
  .toolbar > .flex, .toolbar > label.check { flex: 1 1 100%; max-width: none; min-width: 0; width: 100%; }
  .toolbar > select.input, .toolbar > input.input { min-width: 0; }
}

/* ------------------------------ Variantes de botón -------------------- */
/* Se redeclaran completas para que conserven su color sobre el estilo base */
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--btn-text, #fff); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-600); border-color: var(--primary-600); color: var(--btn-text, #fff); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: var(--success); border-color: var(--success); color: #fff; filter: brightness(1.06); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; filter: brightness(1.06); }
.btn-outline-danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-soft { background: var(--primary-50); border-color: transparent; color: var(--primary); }
.btn-soft:hover { background: var(--primary-100); border-color: transparent; color: var(--primary); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn-wa { background: #25d366; border-color: #25d366; color: #fff; }
.btn-wa:hover { background: #1fb959; border-color: #1fb959; color: #fff; }
.btn[disabled], .btn.disabled { opacity: .6; }
.plano-tools .btn.active { background: var(--primary); border-color: var(--primary); color: var(--btn-text, #fff); }

/* Móvil: los textos largos (correos, códigos, direcciones) se parten en vez de desbordar la pantalla */
@media (max-width: 720px) {
  table.table.como-fichas td, table.table.como-fichas td > *, .cell-sub, .kv, .dl dd { overflow-wrap: anywhere; }
  table.table.como-fichas td.nowrap, table.table.como-fichas td .cell-sub { white-space: normal; }
  .form-actions { flex-wrap: wrap; }
  .form-actions > .btn { flex: 1 1 auto; justify-content: center; }
}

/* Calendario mensual en celulares: días compactos, actividades como puntos y el día completo es tocable */
@media (max-width: 720px) {
  .toolbar:has(.cal-titulo) { align-items: center; }
  .toolbar:has(.cal-titulo) > .spacer { display: none; }
  .cal-titulo { flex: 1 1 0; min-width: 0; font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .toolbar .segmented a { padding: 0 .35rem; gap: .25rem; font-size: .76rem; }
  .toolbar:has(.cal-titulo) > .btn-icon, .toolbar:has(.cal-titulo) > .btn { flex: none; width: auto; }
  .cal-mes .dow { padding: .45rem 0; text-align: center; font-size: .62rem; letter-spacing: .02em; }
  .cal-mes .day { min-height: 56px; padding: .3rem .15rem; display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 4px 0; }
  .cal-mes .day .dn { flex: 0 0 100%; justify-content: center; margin: 0; font-size: .8rem; }
  .cal-mes .day .dn a { position: relative; z-index: 2; }
  .cal-mes .day .dn a.muted { display: none; }
  .cal-mes .day.today .dn a:first-child { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: var(--btn-text, #fff); }
  .cal-mes .day-link { display: block; position: absolute; inset: 0; z-index: 1; }
  .cal-mes .day .ev { display: inline-block; width: 7px; height: 7px; padding: 0; margin: 0 1px; border-radius: 50%; font-size: 0; line-height: 0; vertical-align: middle; pointer-events: none; }
  .cal-mes .day .mas { flex: 0 0 100%; text-align: center; font-size: .62rem; line-height: 1; pointer-events: none; }
  .cal-mes .day .mas span { display: none; }
}
/* Móvil: la celda con título y subtítulo se lee de arriba abajo (no en columnas angostas) */
@media (max-width: 720px) {
  table.table.como-fichas td:has(> .cell-title), table.table.como-fichas td:has(> .cell-sub) { display: block; text-align: left !important; }
  table.table.como-fichas td:not([data-label=""]):has(> .cell-title)::before, table.table.como-fichas td:not([data-label=""]):has(> .cell-sub)::before { display: block; max-width: none; margin-bottom: .15rem; }
  table.table.como-fichas td:has(> .cell-title) .cell-sub, table.table.como-fichas td:has(> .cell-sub) .cell-sub { text-align: left; }
}
