/* ==========================================================================
   MiGente · Hoja de estilos principal
   Mobile-first · Design tokens · Sin dependencias externas
   ========================================================================== */

:root {
  --brand: #0b2a6b;
  --brand-soft: color-mix(in srgb, var(--brand) 10%, white);
  --brand-softer: color-mix(in srgb, var(--brand) 5%, white);
  --brand-strong: color-mix(in srgb, var(--brand) 82%, black);
  --brand-ink: #ffffff;
  --accent: #00aeef;

  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f8;
  --ink: #0b1220;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e5e9f2;
  --line-strong: #d3dae7;

  --success: #0f7a4e;
  --success-bg: #e7f6ef;
  --warn: #a55a07;
  --warn-bg: #fdf1d7;
  --danger: #b42318;
  --danger-bg: #feecea;
  --info: #1d4ed8;
  --info-bg: #e8efff;
  --violet: #0369a1;
  --violet-bg: #e0f2fe;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 8px 24px -12px rgba(15, 23, 42, 0.18), 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, 0.32);

  --header-h: 64px;
  --bottom-nav-h: 72px;
  --sidebar-w: 268px;
  --content-max: 1180px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(900px 420px at 96% -12%, color-mix(in srgb, var(--brand) 9%, transparent), transparent 65%),
    radial-gradient(700px 380px at -10% 8%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.no-scroll {
  overflow: hidden;
}

img,
svg,
canvas {
  max-width: 100%;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: 1.45rem;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.12rem;
  font-weight: 750;
  letter-spacing: -0.015em;
}

h3 {
  font-size: 1rem;
  font-weight: 700;
}

a {
  color: var(--brand);
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

::selection {
  background: color-mix(in srgb, var(--accent) 45%, white);
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 45%, white);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 200;
  background: var(--brand);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
}

.skip-link:focus {
  left: 12px;
}

/* --------------------------------------------------------------------------
   Splash
   -------------------------------------------------------------------------- */

.boot-splash {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 32px;
}

.boot-splash img {
  background: #fff;
  padding: 6px;
  object-fit: contain;
  border-radius: 20px;
  box-shadow: var(--shadow);
  animation: pop 0.5s var(--ease);
}

.boot-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.boot-caption {
  color: var(--muted);
  font-size: 0.9rem;
}

.boot-dots {
  display: flex;
  gap: 6px;
}

.boot-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  opacity: 0.25;
  animation: blink 1s infinite;
}

.boot-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.boot-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes blink {
  0%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@keyframes pop {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   Utilidades
   -------------------------------------------------------------------------- */

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.82rem;
}

.tiny {
  font-size: 0.74rem;
}

.strong {
  font-weight: 700;
}

.nowrap {
  white-space: nowrap;
}

.mono {
  font-family: var(--mono);
  letter-spacing: -0.02em;
}

.grow {
  flex: 1;
  min-width: 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wrap {
  flex-wrap: wrap;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 24px; }
.mt-6 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* --------------------------------------------------------------------------
   Botones
   -------------------------------------------------------------------------- */

.btn {
  --btn-bg: var(--surface);
  --btn-ink: var(--ink);
  --btn-border: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-weight: 650;
  font-size: 0.92rem;
  line-height: 1.1;
  white-space: nowrap;
  transition: transform 0.12s var(--ease), background 0.15s, box-shadow 0.15s, opacity 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.985);
}

.btn:hover {
  box-shadow: var(--shadow-xs);
}

.btn[disabled],
.btn.is-loading {
  opacity: 0.55;
  pointer-events: none;
}

.btn-primary {
  --btn-bg: var(--brand);
  --btn-ink: var(--brand-ink);
  --btn-border: transparent;
  box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--brand) 80%, black);
}

.btn-primary:hover {
  --btn-bg: var(--brand-strong);
}

.btn-soft {
  --btn-bg: var(--brand-soft);
  --btn-ink: var(--brand);
  --btn-border: transparent;
}

.btn-soft:hover {
  --btn-bg: color-mix(in srgb, var(--brand) 16%, white);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-border: transparent;
  --btn-ink: var(--ink-2);
}

.btn-ghost:hover {
  --btn-bg: var(--surface-3);
}

.btn-outline {
  --btn-bg: transparent;
}

.btn-danger {
  --btn-bg: var(--danger);
  --btn-ink: #fff;
  --btn-border: transparent;
}

.btn-danger-soft {
  --btn-bg: var(--danger-bg);
  --btn-ink: var(--danger);
  --btn-border: transparent;
}

.btn-success {
  --btn-bg: var(--success);
  --btn-ink: #fff;
  --btn-border: transparent;
}

.btn-wa {
  --btn-bg: #1fa855;
  --btn-ink: #fff;
  --btn-border: transparent;
}

.btn-sm {
  min-height: 36px;
  padding: 7px 12px;
  font-size: 0.83rem;
  border-radius: 10px;
}

.btn-lg {
  min-height: 50px;
  padding: 13px 20px;
  font-size: 1rem;
  border-radius: 14px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
}

.btn-icon:hover {
  background: var(--surface-3);
}

.btn-icon.bordered {
  border-color: var(--line);
  background: var(--surface);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: var(--ink-2);
  position: relative;
}

.icon-btn:hover {
  background: var(--surface-3);
}

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--bottom-nav-h) + 18px + env(safe-area-inset-bottom));
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 54px;
  padding: 0 20px;
  border-radius: 18px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 16px 30px -12px color-mix(in srgb, var(--brand) 75%, black);
}

.fab:active {
  transform: scale(0.97);
}

@media (min-width: 1024px) {
  .fab {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Tarjetas, badges, chips
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}

.card-pad {
  padding: 16px;
}

.card-hover {
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
}

.card-hover:hover {
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--brand) 22%, var(--line));
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.card-title h2,
.card-title h3 {
  font-size: 0.98rem;
  font-weight: 750;
}

.card-body {
  padding: 16px;
}

.section {
  margin-top: 18px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-head h2 {
  font-size: 1.02rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--ink-2);
}

.badge-brand {
  background: var(--brand-soft);
  color: var(--brand);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-violet {
  background: var(--violet-bg);
  color: var(--violet);
}

.badge-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 6px;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 0.83rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.chip-soft.active {
  background: var(--brand-soft);
  border-color: transparent;
  color: var(--brand);
}

.chip .count {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.22);
  padding: 1px 6px;
  border-radius: 999px;
}

.chip:not(.active) .count {
  background: var(--surface-3);
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Formularios
   -------------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field > label,
.label {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--ink-2);
}

.field .hint {
  font-size: 0.76rem;
  color: var(--muted);
}

.field .error-text {
  font-size: 0.78rem;
  color: var(--danger);
  font-weight: 600;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  appearance: none;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted-2);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--brand) 60%, white);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 12%, transparent);
}

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px var(--danger-bg);
}

.input[disabled],
.select[disabled],
.textarea[disabled] {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}

.textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group .input {
  padding-left: 42px;
}

.input-group .group-icon {
  position: absolute;
  left: 13px;
  color: var(--muted);
  pointer-events: none;
  display: flex;
}

.input-group .group-action {
  position: absolute;
  right: 6px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  color: var(--muted);
}

.input-group .group-action:hover {
  background: var(--surface-3);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 14px;
}

@media (min-width: 560px) {
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid .span-2 {
    grid-column: span 2;
  }
}

.form-section {
  padding: 4px 0 2px;
  margin: 6px 0 12px;
  border-top: 1px dashed var(--line);
}

.form-section:first-child {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.form-section-title {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-2);
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .track {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--line-strong);
  position: relative;
  transition: background 0.15s;
  flex: none;
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-xs);
  transition: transform 0.15s var(--ease);
}

.switch input:checked + .track {
  background: var(--brand);
}

.switch input:checked + .track::after {
  transform: translateX(18px);
}

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}

.search-bar .search-icon {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
}

.search-bar .input {
  padding-left: 40px;
  background: var(--surface);
}

.search-bar .search-clear {
  position: absolute;
  right: 7px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */

.shell {
  min-height: 100dvh;
}

.sidebar {
  display: none;
}

.main {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: color-mix(in srgb, var(--bg) 78%, white);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.topbar-headings {
  display: none;
  min-width: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.topbar-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  box-shadow: var(--shadow-xs);
  flex: none;
}

.topbar-headings {
  min-width: 0;
}

.topbar-title {
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-subtitle {
  font-size: 0.73rem;
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
}

.avatar-btn {
  display: inline-flex;
  padding: 0;
  border-radius: 50%;
}

.bell {
  position: relative;
}

.bell .dot {
  position: absolute;
  top: 7px;
  right: 6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.63rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
}

.context-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: color-mix(in srgb, var(--brand) 7%, white);
  border-bottom: 1px solid color-mix(in srgb, var(--brand) 12%, white);
  font-size: 0.78rem;
  color: var(--brand-strong);
}

.context-bar .grow {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 16px 14px calc(var(--bottom-nav-h) + 28px + env(safe-area-inset-bottom));
  flex: 1;
}

.content--flush {
  padding: 0;
  max-width: none;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.page-head h1 {
  font-size: 1.35rem;
}

.page-head p {
  color: var(--muted);
  font-size: 0.84rem;
  margin-top: 2px;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.desktop-only {
  display: none;
}

.mobile-only {
  display: inline-flex;
}

/* Barra inferior móvil */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--line);
}

.topbar-app {
  font-size: 1.05rem;
  font-weight: 850;
  letter-spacing: -0.035em;
  color: var(--ink);
}

.bottom-nav.nav-4 {
  grid-template-columns: repeat(4, 1fr);
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 650;
  min-height: 52px;
  position: relative;
}

.bottom-nav a.active {
  color: var(--brand);
  background: var(--brand-softer);
}

.bottom-nav a .nav-dot {
  position: absolute;
  top: 8px;
  right: calc(50% - 17px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
}

@media (min-width: 1024px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--line);
    z-index: 50;
    padding: 18px 14px;
    overflow-y: auto;
  }

  .main {
    margin-left: var(--sidebar-w);
  }

  .topbar {
    padding: 0 26px;
    background: color-mix(in srgb, var(--bg) 82%, white);
  }

  .topbar-brand .topbar-logo {
    display: none;
  }

  .topbar-headings {
    display: block;
  }

  .topbar-actions {
    margin-left: auto;
  }

  .content {
    padding: 26px 26px 60px;
  }

  .bottom-nav,
  .fab {
    display: none;
  }

  .desktop-only {
    display: flex;
  }

  .mobile-only {
    display: none;
  }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px 18px;
}

.sidebar-brand img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  background: #fff;
  border-radius: 11px;
  box-shadow: var(--shadow-sm);
}

.sidebar-brand .name {
  font-size: 1.15rem;
  font-weight: 850;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.sidebar-brand .tag {
  font-size: 0.67rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.tenant-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, var(--brand-softer), var(--surface));
  margin-bottom: 16px;
  text-align: left;
  width: 100%;
}

.tenant-switch:hover {
  border-color: color-mix(in srgb, var(--brand) 30%, var(--line));
}

.tenant-switch .crest {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.82rem;
  flex: none;
}

.tenant-switch .name {
  display: block;
  font-size: 0.8rem;
  font-weight: 750;
  line-height: 1.2;
}

.tenant-switch .sub {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
}

.nav-group {
  margin-bottom: 16px;
}

.nav-group-label {
  font-size: 0.64rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-2);
  padding: 0 10px;
  margin-bottom: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 9px 11px;
  border-radius: 11px;
  color: var(--ink-2);
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 2px;
  position: relative;
}

.nav-link svg {
  color: var(--muted);
}

.nav-link:hover {
  background: var(--surface-2);
}

.nav-link.active {
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 700;
}

.nav-link.active svg {
  color: var(--brand);
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}

.nav-link .nav-badge {
  margin-left: auto;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 12px;
}

.sidebar-user:hover {
  background: var(--surface-2);
}

.sidebar-user .meta {
  min-width: 0;
  flex: 1;
}

.sidebar-user .meta strong {
  display: block;
  font-size: 0.82rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .meta span {
  font-size: 0.7rem;
  color: var(--muted);
}

.sidebar-version {
  margin-top: 8px;
  padding: 0 8px;
  font-size: 0.66rem;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.02em;
}

.version-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.version-pill:hover {
  color: var(--text);
  border-color: var(--brand);
}

.registraduria-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--brand);
  border-radius: 14px;
  background: var(--surface-2);
}

.registraduria-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.registraduria-panel .form-grid {
  margin-top: 4px;
}

@media (max-width: 640px) {
  .version-pill {
    padding: 3px 6px;
    font-size: 0.62rem;
  }
}

.version-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.12);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Avatares
   -------------------------------------------------------------------------- */

.avatar {
  --av-size: 40px;
  width: var(--av-size);
  height: var(--av-size);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 750;
  font-size: calc(var(--av-size) * 0.36);
  color: #fff;
  flex: none;
  overflow: hidden;
  position: relative;
  background: var(--brand);
  letter-spacing: -0.02em;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar.sm {
  --av-size: 32px;
}

.avatar.md {
  --av-size: 46px;
}

.avatar.lg {
  --av-size: 64px;
}

.avatar.xl {
  --av-size: 88px;
}

.avatar.ring {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--brand-soft);
}

.avatar-stack {
  display: flex;
  align-items: center;
}

.avatar-stack .avatar {
  border: 2px solid var(--surface);
  margin-left: -9px;
}

.avatar-stack .avatar:first-child {
  margin-left: 0;
}

.avatar-online::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--surface);
}

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */

.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
}

.auth-brand {
  display: none;
  position: relative;
  overflow: hidden;
  padding: 46px;
  color: #fff;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(0, 174, 239, 0.28), transparent 55%),
    radial-gradient(700px 500px at 100% 100%, rgba(37, 99, 235, 0.35), transparent 55%),
    linear-gradient(150deg, #03122e 0%, #08245c 45%, #0b3e9c 100%);
  flex-direction: column;
  justify-content: space-between;
}

.auth-brand::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  right: -180px;
  bottom: -220px;
  box-shadow: 0 0 0 60px rgba(255, 255, 255, 0.03), 0 0 0 130px rgba(255, 255, 255, 0.025);
}

.auth-brand-inner {
  max-width: 460px;
  position: relative;
  z-index: 1;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 54px;
}

.auth-logo img {
  width: 50px;
  height: 50px;
  padding: 6px;
  object-fit: contain;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.6);
}

.auth-logo .name {
  font-size: 1.4rem;
  font-weight: 850;
  letter-spacing: -0.035em;
}

.auth-brand h1 {
  font-size: 2.5rem;
  line-height: 1.08;
  letter-spacing: -0.045em;
  font-weight: 850;
}

.auth-brand h1 em {
  font-style: normal;
  color: #5ed2ff;
}

.auth-brand p {
  margin-top: 18px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 1rem;
  line-height: 1.6;
}

.auth-features {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-feature {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.85);
}

.auth-feature .ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.auth-feature strong {
  display: block;
  color: #fff;
  font-size: 0.9rem;
}

.auth-feature span {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8rem;
}

.auth-foot {
  position: relative;
  z-index: 1;
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.45);
}

.auth-foot .version-badge {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.72);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 26px 18px calc(26px + env(safe-area-inset-bottom));
  background: var(--surface);
}

.auth-form-wrap {
  width: 100%;
  max-width: 400px;
  animation: rise 0.35s var(--ease);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.auth-mobile-brand img {
  width: 44px;
  height: 44px;
  padding: 5px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--shadow-sm);
}

.auth-mobile-brand .name {
  font-size: 1.25rem;
  font-weight: 850;
  letter-spacing: -0.035em;
}

.auth-form-wrap h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.auth-sub {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 4px 0 22px;
}

.auth-form .btn {
  margin-top: 6px;
}

.auth-error {
  display: none;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.auth-error.show {
  display: flex;
}

.auth-error svg {
  flex: none;
  margin-top: 1px;
}

.auth-tenants {
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.auth-tenants h3 {
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.auth-tenant-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  margin-top: 6px;
  text-align: left;
}

.auth-tenant-option:hover {
  border-color: var(--brand);
}

.auth-tenant-option .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.auth-tenant-option strong {
  font-size: 0.83rem;
  display: block;
}

.auth-tenant-option span {
  font-size: 0.72rem;
  color: var(--muted);
}

.auth-help-note {
  margin-top: 8px;
  font-size: 0.7rem;
  color: var(--muted-2);
}

@media (min-width: 900px) {
  .auth {
    grid-template-columns: minmax(420px, 46%) 1fr;
  }

  .auth-brand {
    display: flex;
  }

  .auth-panel {
    padding: 40px;
  }

  .auth-mobile-brand {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   KPIs y dashboard
   -------------------------------------------------------------------------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (min-width: 760px) {
  .kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
  }
}

.kpi {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-soft);
  color: var(--brand);
  flex: none;
}

.kpi-icon.success {
  background: var(--success-bg);
  color: var(--success);
}

.kpi-icon.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.kpi-icon.violet {
  background: var(--violet-bg);
  color: var(--violet);
}

.kpi-icon.info {
  background: var(--info-bg);
  color: var(--info);
}

.kpi-value {
  font-size: 1.55rem;
  font-weight: 820;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.kpi-label {
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 600;
}

.kpi-foot {
  font-size: 0.7rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.kpi-foot .up {
  color: var(--success);
  font-weight: 700;
}

.dash-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 20px;
  color: #fff;
  background:
    radial-gradient(500px 260px at 100% 0%, rgba(0, 174, 239, 0.32), transparent 60%),
    linear-gradient(135deg, var(--brand-strong), var(--brand) 65%, color-mix(in srgb, var(--brand) 70%, #1450b4));
  box-shadow: 0 18px 40px -22px color-mix(in srgb, var(--brand) 80%, black);
}

.dash-hero::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -80px;
  width: 230px;
  height: 230px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 30px rgba(255, 255, 255, 0.04), 0 0 0 70px rgba(255, 255, 255, 0.03);
}

.dash-hero h1 {
  font-size: 1.4rem;
  letter-spacing: -0.03em;
  max-width: 520px;
}

.dash-hero p {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.84rem;
  margin-top: 4px;
}

.dash-hero-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  position: relative;
  z-index: 1;
  flex-wrap: wrap;
}

.dash-hero .btn-primary {
  --btn-bg: #fff;
  --btn-ink: var(--brand-strong);
  --btn-border: transparent;
}

.dash-hero .btn-ghost {
  --btn-ink: #fff;
  --btn-bg: rgba(255, 255, 255, 0.12);
  --btn-border: rgba(255, 255, 255, 0.18);
}

.goal-ring {
  --pct: 0;
  --size: 92px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), rgba(255, 255, 255, 0.16) 0);
  display: grid;
  place-items: center;
  flex: none;
}

.goal-ring::before {
  content: "";
  width: calc(var(--size) - 14px);
  height: calc(var(--size) - 14px);
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand) 88%, black);
  grid-area: 1 / 1;
}

.goal-ring span {
  grid-area: 1 / 1;
  z-index: 1;
  font-weight: 820;
  font-size: 1.05rem;
  letter-spacing: -0.03em;
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 900px) {
  .dash-grid {
    grid-template-columns: 1.55fr 1fr;
    align-items: start;
  }
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 170px;
}

.chart-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.72rem;
  color: var(--muted);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
}

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.bar-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.79rem;
}

.bar-meta span:last-child {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 55%, var(--accent)));
  transition: width 0.5s var(--ease);
}

.top-list {
  display: flex;
  flex-direction: column;
}

.top-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.top-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.top-item:first-child {
  padding-top: 0;
}

.rank {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.top-item:first-child .rank {
  background: var(--brand);
  color: #fff;
}

.alert-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.8rem;
}

.alert .ico {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: var(--info-bg);
  color: var(--info);
}

.alert.warning .ico {
  background: var(--warn-bg);
  color: var(--warn);
}

.alert.goal .ico {
  background: var(--success-bg);
  color: var(--success);
}

.alert.promotion .ico {
  background: var(--violet-bg);
  color: var(--violet);
}

.alert strong {
  display: block;
  font-size: 0.8rem;
  line-height: 1.35;
}

.alert p {
  color: var(--muted);
  font-size: 0.74rem;
  margin-top: 1px;
}

.alert a {
  font-weight: 700;
  font-size: 0.74rem;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.activity-item {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.78rem;
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-item .ico {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand-softer);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.activity-item .when {
  color: var(--muted-2);
  font-size: 0.68rem;
}

/* --------------------------------------------------------------------------
   Listas de personas
   -------------------------------------------------------------------------- */

.person-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.person {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.person:hover {
  border-color: color-mix(in srgb, var(--brand) 26%, var(--line));
  box-shadow: var(--shadow-xs);
}

.person .who {
  min-width: 0;
  flex: 1;
}

.person .name {
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person .meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.74rem;
  margin-top: 2px;
  flex-wrap: wrap;
}

.person .aside {
  flex: none;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.person .date {
  font-size: 0.68rem;
  color: var(--muted-2);
  white-space: nowrap;
}

.person-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 700px) {
  .person-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.photo-bubble {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  overflow: hidden;
  flex: none;
  background: var(--brand-soft);
}

.photo-bubble img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --------------------------------------------------------------------------
   Árbol de red
   -------------------------------------------------------------------------- */

.tree-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.tree-stat {
  padding: 11px;
  border-radius: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: center;
}

.tree-stat strong {
  display: block;
  font-size: 1.15rem;
  font-weight: 820;
  letter-spacing: -0.03em;
}

.tree-stat span {
  font-size: 0.7rem;
  color: var(--muted);
}

.tree {
  font-size: 0.86rem;
}

.tree ul {
  list-style: none;
  margin: 0;
  padding-left: 20px;
  position: relative;
}

.tree > ul {
  padding-left: 0;
}

.tree ul::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 18px;
  width: 2px;
  background: var(--line);
  border-radius: 2px;
}

.tree > ul::before {
  display: none;
}

.tree li {
  position: relative;
  padding: 4px 0;
}

.tree ul li::before {
  content: "";
  position: absolute;
  left: -13px;
  top: 30px;
  width: 13px;
  height: 2px;
  background: var(--line);
}

.tree > ul > li::before {
  display: none;
}

.tree-node {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  width: 100%;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.tree-node:hover {
  border-color: color-mix(in srgb, var(--brand) 30%, var(--line));
}

.tree-node.root {
  background: linear-gradient(150deg, var(--brand-softer), var(--surface));
  border-color: color-mix(in srgb, var(--brand) 25%, var(--line));
}

.tree-node .who {
  min-width: 0;
  flex: 1;
}

.tree-node .name {
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-node .meta {
  font-size: 0.68rem;
  color: var(--muted);
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.tree-toggle {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex: none;
}

.tree-toggle:hover {
  background: var(--surface-3);
}

.tree-children {
  display: none;
}

.tree-children.open {
  display: block;
}

.tree-node .node-badge {
  font-size: 0.64rem;
  padding: 2px 6px;
}

.upline-chain {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.upline-chain a {
  color: var(--ink-2);
  font-weight: 650;
}

/* --------------------------------------------------------------------------
   Chat
   -------------------------------------------------------------------------- */

.chat-layout {
  display: grid;
  grid-template-columns: 1fr;
  height: calc(100dvh - var(--header-h) - var(--bottom-nav-h) - env(safe-area-inset-bottom));
  background: var(--surface);
}

@media (min-width: 1024px) {
  .chat-layout {
    height: calc(100dvh - var(--header-h));
    grid-template-columns: 344px minmax(0, 1fr);
    border-left: 1px solid var(--line);
  }
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.chat-sidebar-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.thread {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 13px;
  text-align: left;
  position: relative;
}

.thread:hover {
  background: var(--surface-2);
}

.thread.active {
  background: var(--brand-soft);
}

.thread .who {
  min-width: 0;
  flex: 1;
}

.thread .name {
  font-size: 0.84rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread .preview {
  font-size: 0.73rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.thread .preview.unread {
  color: var(--ink-2);
  font-weight: 650;
}

.thread .aside {
  flex: none;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.thread .time {
  font-size: 0.64rem;
  color: var(--muted-2);
}

.thread .unread {
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.64rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.thread-team {
  margin: 6px;
  border: 1px solid color-mix(in srgb, var(--brand) 20%, var(--line));
  background: linear-gradient(140deg, var(--brand-soft), var(--surface));
}

.thread-team .team-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.chat-main {
  display: none;
  flex-direction: column;
  min-height: 0;
  background: var(--surface-2);
  position: relative;
}

.chat-main.open {
  display: flex;
}

.chat-head {
  height: 58px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.chat-head .who {
  min-width: 0;
  flex: 1;
}

.chat-head .name {
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-head .meta {
  font-size: 0.7rem;
  color: var(--muted);
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  scroll-behavior: smooth;
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  max-width: 280px;
  padding: 24px;
}

.chat-empty .ico {
  width: 52px;
  height: 52px;
  margin: 0 auto 10px;
  border-radius: 16px;
  background: var(--brand-soft);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
}

.day-sep {
  align-self: center;
  font-size: 0.66rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: 999px;
  margin: 8px 0 4px;
}

.msg {
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-self: flex-start;
}

.msg.mine {
  align-self: flex-end;
  align-items: flex-end;
}

.msg .sender {
  font-size: 0.66rem;
  color: var(--muted);
  padding: 0 5px;
}

.bubble {
  padding: 9px 12px;
  border-radius: 15px;
  border-bottom-left-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.87rem;
  line-height: 1.42;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow-xs);
}

.msg.mine .bubble {
  background: var(--brand);
  color: #fff;
  border-color: transparent;
  border-bottom-left-radius: 15px;
  border-bottom-right-radius: 5px;
}

.msg .stamp {
  font-size: 0.63rem;
  color: var(--muted-2);
  padding: 0 5px;
}

.msg.mine .stamp {
  color: color-mix(in srgb, var(--brand) 45%, var(--muted));
}

.chat-compose {
  flex: none;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: flex-end;
  gap: 7px;
}

.chat-compose textarea {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  padding: 10px 13px;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  font-size: 0.9rem;
  resize: none;
  line-height: 1.35;
}

.chat-compose textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: opacity 0.15s, transform 0.12s;
}

.send-btn[disabled] {
  opacity: 0.4;
}

.send-btn:active {
  transform: scale(0.94);
}

.chat-notice {
  padding: 10px 14px;
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--surface);
  border-top: 1px solid var(--line);
  text-align: center;
}

@media (min-width: 1024px) {
  .chat-main {
    display: flex;
  }

  .chat-back {
    display: none;
  }
}

@media (max-width: 1023px) {
  .chat-layout.thread-open .chat-sidebar {
    display: none;
  }

  .chat-layout.thread-open .chat-main {
    display: flex;
  }
}

/* --------------------------------------------------------------------------
   WhatsApp
   -------------------------------------------------------------------------- */

.wa-status {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px;
  border-radius: 14px;
  background: var(--success-bg);
  border: 1px solid color-mix(in srgb, var(--success) 18%, white);
  color: var(--success);
  font-size: 0.8rem;
}

.wa-status.off {
  background: var(--warn-bg);
  border-color: color-mix(in srgb, var(--warn) 18%, white);
  color: var(--warn);
}

.wa-status .ico {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.wa-status strong {
  display: block;
  font-size: 0.84rem;
}

.wa-status span {
  color: color-mix(in srgb, currentColor 75%, var(--ink));
  font-size: 0.75rem;
}

.var-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.var-chip {
  font-family: var(--mono);
  font-size: 0.68rem;
  padding: 3px 7px;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

.wa-preview {
  background: #e7ffe9;
  border-radius: 14px;
  padding: 12px;
  border: 1px solid #c9efcd;
}

.wa-bubble {
  background: #fff;
  border-radius: 10px 10px 10px 3px;
  padding: 9px 11px;
  font-size: 0.84rem;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 420px;
}

.wa-meta {
  font-size: 0.64rem;
  color: #5f7a63;
  text-align: right;
  margin-top: 3px;
}

.recipient-list {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.recipient-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 0.79rem;
}

.recipient-row:last-child {
  border-bottom: 0;
}

.recipient-row .phone {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.guided-card {
  border: 1px solid color-mix(in srgb, #1fa855 25%, var(--line));
  border-radius: 14px;
  padding: 13px;
  background: linear-gradient(160deg, #f2fcf5, var(--surface));
}

.guided-progress {
  height: 7px;
  border-radius: 99px;
  background: #d8f0de;
  overflow: hidden;
  margin: 8px 0 12px;
}

.guided-progress span {
  display: block;
  height: 100%;
  background: #1fa855;
  border-radius: inherit;
  transition: width 0.3s var(--ease);
}

.wa-campaign {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  width: 100%;
  text-align: left;
}

.wa-campaign:hover {
  border-color: var(--line-strong);
}

.wa-campaign .ico {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: #e6f9ec;
  color: #1fa855;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.wa-campaign .body {
  min-width: 0;
  flex: 1;
}

.wa-campaign .title {
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-campaign .meta {
  font-size: 0.7rem;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Modales / sheets
   -------------------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(8, 14, 28, 0.52);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade 0.18s var(--ease);
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet {
  width: 100%;
  max-width: 100%;
  max-height: 92dvh;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slide-up 0.24s var(--ease);
  overflow: hidden;
}

@keyframes slide-up {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  font-size: 1.02rem;
  flex: 1;
  min-width: 0;
}

.sheet-head .sub {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 500;
  margin-top: 1px;
}

.sheet-body {
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.sheet-foot {
  flex: none;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  gap: 8px;
}

.sheet-foot .btn {
  flex: 1;
}

.sheet.wide {
  max-width: 100%;
}

.sheet.fullscreen {
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
}

@media (min-width: 640px) {
  .overlay {
    align-items: center;
    padding: 24px;
  }

  .sheet {
    max-width: 540px;
    border-radius: 20px;
    max-height: min(88dvh, 900px);
  }

  .sheet.wide {
    max-width: 760px;
  }

  .sheet.fullscreen {
    height: auto;
    max-height: min(90dvh, 920px);
    border-radius: 20px;
  }

  .sheet-foot .btn {
    flex: 0 0 auto;
    min-width: 110px;
    margin-left: auto;
  }
}

.sheet-grab {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: var(--line-strong);
  margin: 8px auto 0;
  flex: none;
}

@media (min-width: 640px) {
  .sheet-grab {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--bottom-nav-h) + 14px + env(safe-area-inset-bottom));
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

@media (min-width: 1024px) {
  .toasts {
    left: auto;
    right: 22px;
    top: 78px;
    bottom: auto;
    width: 360px;
  }
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 13px;
  background: #101827;
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 0.82rem;
  animation: toast-in 0.24s var(--ease);
}

.toast.success {
  background: #0c5c3d;
}

.toast.error {
  background: #7f1d1d;
}

.toast.warn {
  background: #7a4a08;
}

.toast .ico {
  flex: none;
  margin-top: 1px;
}

.toast .txt {
  flex: 1;
  min-width: 0;
}

.toast .txt strong {
  display: block;
  font-size: 0.82rem;
}

.toast .txt span {
  display: block;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.76rem;
}

.toast button {
  color: rgba(255, 255, 255, 0.6);
  flex: none;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@keyframes toast-in {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* --------------------------------------------------------------------------
   Estados: vacío, carga, error
   -------------------------------------------------------------------------- */

.empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--muted);
}

.empty .ico {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-soft);
  color: var(--brand);
}

.empty strong {
  display: block;
  color: var(--ink);
  font-size: 0.92rem;
  margin-bottom: 3px;
}

.empty p {
  font-size: 0.8rem;
  max-width: 340px;
  margin: 0 auto 14px;
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, #f6f8fc 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  from { background-position: 100% 50%; }
  to { background-position: 0 50%; }
}

.skeleton-line {
  height: 12px;
  margin-bottom: 8px;
}

.skeleton-card {
  height: 82px;
  border-radius: 14px;
  margin-bottom: 8px;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.btn .spinner {
  border-color: color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  width: 15px;
  height: 15px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-block {
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.loading-block .spinner {
  color: var(--brand);
  border-color: var(--line);
  border-top-color: var(--brand);
  width: 26px;
  height: 26px;
}

.error-block {
  padding: 26px 18px;
  text-align: center;
}

.error-block .ico {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--danger-bg);
  color: var(--danger);
}

.error-block p {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 4px 0 12px;
}

/* --------------------------------------------------------------------------
   Perfil, ajustes, tablas
   -------------------------------------------------------------------------- */

.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius);
  background: linear-gradient(150deg, var(--brand-soft), var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand) 16%, var(--line));
}

.profile-head .who {
  min-width: 0;
}

.profile-head h2 {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.profile-head .meta {
  color: var(--muted);
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 3px;
}

.menu-list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  width: 100%;
  text-align: left;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  min-height: 52px;
}

.menu-item:last-child {
  border-bottom: 0;
}

.menu-item:hover {
  background: var(--surface-2);
}

.menu-item .ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.menu-item.danger .ico {
  background: var(--danger-bg);
  color: var(--danger);
}

.menu-item.danger {
  color: var(--danger);
}

.menu-item .chev {
  margin-left: auto;
  color: var(--muted-2);
}

.menu-item .tag {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface-3);
  border-radius: 12px;
  margin-bottom: 14px;
}

.tab {
  flex: 1;
  min-height: 37px;
  border-radius: 9px;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}

.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

.data-item {
  min-width: 0;
}

.data-item dt {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-2);
  font-weight: 700;
  margin-bottom: 2px;
}

.data-item dd {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.danger-zone {
  border: 1px solid color-mix(in srgb, var(--danger) 22%, var(--line));
  background: var(--danger-bg);
  border-radius: 14px;
  padding: 14px;
}

.danger-zone h3 {
  color: var(--danger);
  font-size: 0.88rem;
}

.danger-zone p {
  color: color-mix(in srgb, var(--danger) 75%, var(--ink));
  font-size: 0.78rem;
  margin: 4px 0 10px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  min-width: 620px;
}

.table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table tr:hover td {
  background: var(--surface-2);
}

/* --------------------------------------------------------------------------
   Carga de foto
   -------------------------------------------------------------------------- */

.photo-field {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 14px;
  border: 1px dashed var(--line-strong);
  background: var(--surface-2);
}

.photo-preview {
  width: 78px;
  height: 78px;
  border-radius: 16px;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  overflow: hidden;
  flex: none;
  border: 1px solid var(--line);
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.photo-actions .hint {
  font-size: 0.72rem;
  color: var(--muted);
}

.camera-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Superadmin / campañas
   -------------------------------------------------------------------------- */

.tenant-card {
  padding: 15px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.tenant-card:hover {
  border-color: color-mix(in srgb, var(--brand) 28%, var(--line));
  box-shadow: var(--shadow);
}

.tenant-card .top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tenant-card .crest {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  flex: none;
}

.tenant-card .name {
  font-weight: 750;
  font-size: 0.9rem;
  line-height: 1.2;
}

.tenant-card .candidate {
  font-size: 0.74rem;
  color: var(--muted);
}

.tenant-card .stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.tenant-card .stats div {
  text-align: center;
}

.tenant-card .stats strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tenant-card .stats span {
  font-size: 0.66rem;
  color: var(--muted);
}

.tenant-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 760px) {
  .tenant-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1180px) {
  .tenant-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.temp-password {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-3);
  border: 1px dashed var(--line-strong);
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  justify-content: space-between;
}

.hint-box {
  display: flex;
  gap: 9px;
  padding: 11px 12px;
  border-radius: 12px;
  background: var(--info-bg);
  color: color-mix(in srgb, var(--info) 85%, var(--ink));
  font-size: 0.78rem;
  line-height: 1.45;
}

.hint-box.warn {
  background: var(--warn-bg);
  color: color-mix(in srgb, var(--warn) 85%, var(--ink));
}

.hint-box .ico {
  flex: none;
  margin-top: 1px;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}

.copy-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.kbd {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 2px 5px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
}

.stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
}

.stepper .step {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: var(--line);
}

.stepper .step.done {
  background: var(--brand);
}

/* --------------------------------------------------------------------------
   Animaciones de vista
   -------------------------------------------------------------------------- */

.view-enter {
  animation: view-in 0.22s var(--ease);
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}



/* --------------------------------------------------------------------------
   Ajustes móviles finos
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .page-head > div:first-child {
    min-width: 0;
  }

  .page-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .person .name,
  .thread .name {
    display: block;
  }

  .person .aside {
    align-self: flex-start;
    max-width: 86px;
  }

  .person .who {
    overflow: hidden;
  }

  .thread .preview {
    display: block;
    max-width: 100%;
  }

  .tree ul {
    padding-left: 14px;
  }

  .tree ul li::before {
    left: -10px;
    width: 10px;
  }

  .tree ul::before {
    left: 5px;
  }

  .tree-node .name {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .tree-node .aside {
    max-width: 92px;
  }

  .tree-node {
    padding: 8px;
    gap: 7px;
  }
}
/* Chat: contención de textos largos */
.chat-layout,
.chat-sidebar,
.chat-main,
.chat-list {
  min-width: 0;
}

.chat-sidebar {
  overflow: hidden;
}

.chat-list {
  overflow-x: hidden;
}

.thread {
  min-width: 0;
  overflow: hidden;
}

.thread .who {
  overflow: hidden;
}

.thread .name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .person .date {
    display: none;
  }

  .person .name {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .person .aside {
    max-width: 72px;
  }

  .wa-status .badge {
    display: none;
  }

  .wa-status .grow {
    flex-basis: 0;
  }
}
/* Auditoría legible */
.audit-message {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--ink-2);
}

.audit-table td.audit-message {
  min-width: 360px;
}

.audit-item .audit-message {
  font-size: 0.85rem;
  color: var(--ink);
}

@media (max-width: 640px) {
  .audit-item .audit-message {
    font-size: 0.86rem;
  }
}
/* Logo de campaña */
.tenant-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.tenant-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.logo-editor {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.logo-preview {
  width: 76px;
  height: 76px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-initials {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 1.2rem;
}

@media (max-width: 640px) {
  .logo-editor {
    align-items: flex-start;
  }
}