/* ==========================================================================
   Waflow — Variante "Office Plus"
   Paleta slate de producción · Manrope · acento sky · botones suaves
   Activo solo cuando el body tiene la clase .v3
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* --------------------------------------------------------------------------
   Tokens — paleta slate (igual que producción) + acento sky
   -------------------------------------------------------------------------- */
body.v3 {
  --font-display: 'Manrope', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-sans: 'Manrope', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* superficies — slate base */
  --bg: #f1f5f9;          /* slate-100 — el de producción */
  --surface: #ffffff;
  --surface-soft: #f8fafc; /* slate-50 */
  --surface-sunk: #f1f5f9;

  /* hairlines */
  --hairline: #e2e8f0;    /* slate-200 */
  --hairline-strong: #cbd5e1; /* slate-300 */

  /* tinta */
  --ink: #0f172a;         /* slate-900 */
  --ink-soft: #475569;    /* slate-600 */
  --ink-faint: #64748b;   /* slate-500 */

  /* acento — sky (azul cielo, profesional pero alegre) */
  --accent: #0284c7;       /* sky-600 */
  --accent-soft: #0ea5e9;  /* sky-500 */
  --accent-strong: #0369a1; /* sky-700 */
  --accent-tint: #e0f2fe;  /* sky-100 */
  --accent-on: #ffffff;

  /* color de ACCIÓN — slate-800 (azul-gris, no negro) */
  --action: #1e293b;       /* slate-800 */
  --action-hover: #0f172a; /* slate-900 al hover */
  --action-active: #334155; /* slate-700 */
  --action-on: #ffffff;

  /* semánticos */
  --success: #059669;      /* emerald-600 */
  --success-tint: #d1fae5; /* emerald-100 */
  --warning: #d97706;      /* amber-600 */
  --warning-tint: #fef3c7; /* amber-100 */
  --danger:  #dc2626;      /* red-600 */
  --danger-tint: #fee2e2;  /* red-100 */
  --info:    #0284c7;      /* sky-600 */
  --info-tint: #e0f2fe;    /* sky-100 */

  /* sombras suaves */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 8px -2px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);

  /* radios — un toque más generosos (estilo software amigable) */
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  --radius-2xl: 20px;

  background: var(--bg);
  background-image: none;
  font-family: var(--font-sans);
  letter-spacing: -0.005em;
  color: var(--ink);
}

html[data-theme='dark'] body.v3 {
  --bg: #020617;          /* slate-950 */
  --surface: #0f172a;     /* slate-900 */
  --surface-soft: #1e293b; /* slate-800 */
  --surface-sunk: #0b1220;

  --hairline: #1e293b;
  --hairline-strong: #334155;

  --ink: #e2e8f0;
  --ink-soft: #cbd5e1;
  --ink-faint: #94a3b8;

  --accent: #38bdf8;       /* sky-400 */
  --accent-soft: #7dd3fc;  /* sky-300 */
  --accent-strong: #0ea5e9;
  --accent-tint: rgba(56, 189, 248, 0.14);
  --accent-on: #0f172a;

  --action: #e2e8f0;
  --action-hover: #f8fafc;
  --action-active: #cbd5e1;
  --action-on: #0f172a;

  --success: #10b981;
  --success-tint: rgba(16, 185, 129, 0.14);
  --warning: #f59e0b;
  --warning-tint: rgba(245, 158, 11, 0.14);
  --danger:  #f87171;
  --danger-tint: rgba(248, 113, 113, 0.14);
  --info:    #38bdf8;
  --info-tint: rgba(56, 189, 248, 0.14);
}

/* --------------------------------------------------------------------------
   Tipografía — Manrope, sin serif, sin cursiva, jerarquía amigable
   -------------------------------------------------------------------------- */
body.v3 .display-xl,
body.v3 .display-lg,
body.v3 .display-md,
body.v3 .display-sm {
  font-family: var(--font-sans);
  font-weight: 700;
  font-style: normal;
  letter-spacing: -0.022em;
  line-height: 1.2;
}

body.v3 .display-xl { font-size: 2.25rem; line-height: 1.1; }
body.v3 .display-lg { font-size: 1.625rem; }
body.v3 .display-md { font-size: 1.25rem; }
body.v3 .display-sm { font-size: 1rem; font-weight: 600; }

body.v3 em { font-style: normal; color: var(--ink); }

body.v3 .eyebrow {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-faint);
}

body.v3 .num-tag,
body.v3 .eyebrow-num {
  display: none;
}

body.v3 .section-divider::after { display: none; }
body.v3 .section-divider { margin: 1.75rem 0 0.75rem; }

body.v3 .field-label {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 0.4rem;
  letter-spacing: 0;
}

/* --------------------------------------------------------------------------
   Topbar — limpia, sólida, con activo en sky
   -------------------------------------------------------------------------- */
body.v3 .topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.v3 .topbar-brand-name {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.025em;
  color: var(--ink);
}

body.v3 .topbar-brand-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

body.v3 .topbar-link {
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-soft);
}

body.v3 .topbar-link:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

body.v3 .topbar-link[aria-current='page'] {
  background: var(--accent-tint);
  color: var(--accent-strong);
  font-weight: 600;
}

body.v3 .topbar-link[aria-current='page']::after {
  display: none;
}

body.v3 .topbar-tenant {
  background: var(--surface-soft);
  border-color: var(--hairline);
  font-weight: 500;
}

body.v3 .topbar-tenant-avatar {
  background: var(--accent);
  color: var(--accent-on);
  font-family: var(--font-sans);
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   BOTONES — visibles pero suaves, no agresivos
   -------------------------------------------------------------------------- */
body.v3 .btn {
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9375rem;
  padding: 0.75rem 1.35rem;
  letter-spacing: -0.005em;
  line-height: 1.2;
  height: 46px;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 100ms ease;
}

body.v3 .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.v3 .btn-sm {
  height: 40px;
  padding: 0.55rem 1.1rem;
  font-size: 0.875rem;
}

body.v3 .btn-lg {
  height: 56px;
  padding: 1rem 2rem;
  font-size: 1.0625rem;
  font-weight: 700;
  border-radius: var(--radius-lg);
}

/* primario = slate-800 (azul-gris oscuro), no negro */
body.v3 .btn-primary {
  background: var(--action);
  color: var(--action-on);
  border-color: var(--action);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

body.v3 .btn-primary:hover:not(:disabled) {
  background: var(--action-hover);
  border-color: var(--action-hover);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

body.v3 .btn-primary:active:not(:disabled) {
  background: var(--action-active);
  transform: translateY(1px);
}

/* btn-accent — azul sky, CTA principal grande y prominente */
body.v3 .btn-accent {
  background: var(--accent);
  color: var(--accent-on);
  border: 1px solid var(--accent);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  font-weight: 700;
  border-radius: var(--radius-lg);
  padding: 1rem 2rem;
  font-size: 1.0625rem;
  height: 56px;
  min-width: 200px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-family: var(--font-sans);
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease, border-color 160ms ease;
}

body.v3 .btn-accent:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

body.v3 .btn-accent:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* ghost — blanco con borde claro pero presente */
body.v3 .btn-ghost {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--hairline-strong);
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.03);
}

body.v3 .btn-ghost:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: var(--ink-faint);
}

/* botones de acción específica — fondo tint, texto saturado */
body.v3 .btn-warning {
  background: var(--warning-tint);
  color: var(--warning);
  border: 1px solid color-mix(in srgb, var(--warning) 22%, transparent);
}
body.v3 .btn-warning:hover:not(:disabled) {
  background: color-mix(in srgb, var(--warning-tint) 60%, var(--warning) 30%);
  color: var(--surface);
  border-color: var(--warning);
}

body.v3 .btn-danger {
  background: var(--danger-tint);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent);
}
body.v3 .btn-danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger-tint) 60%, var(--danger) 30%);
  color: var(--surface);
  border-color: var(--danger);
}

body.v3 .btn-info {
  background: var(--info-tint);
  color: var(--info);
  border: 1px solid color-mix(in srgb, var(--info) 22%, transparent);
}
body.v3 .btn-info:hover:not(:disabled) {
  background: color-mix(in srgb, var(--info-tint) 60%, var(--info) 30%);
  color: var(--surface);
  border-color: var(--info);
}

/* --------------------------------------------------------------------------
   Cards — radius generoso, sombra suave
   -------------------------------------------------------------------------- */
body.v3 .surface-card {
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xs);
  background: var(--surface);
  border: 1px solid var(--hairline);
}

body.v3 .surface-sunk {
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid var(--hairline);
}

/* --------------------------------------------------------------------------
   Stat tiles — más friendly, número en peso pleno
   -------------------------------------------------------------------------- */
body.v3 .stat-tile {
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

body.v3 .stat-tile:hover {
  border-color: var(--hairline-strong);
  box-shadow: var(--shadow-sm);
}

body.v3 .stat-tile::before { display: none; }

body.v3 .stat-tile-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-faint);
}

body.v3 .stat-tile-value {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.875rem;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--ink);
  margin-top: 0.5rem;
  font-variant-numeric: tabular-nums;
}

body.v3 .stat-tile-trend {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 0.4rem;
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Status pill — visible y clara
   -------------------------------------------------------------------------- */
body.v3 .status-pill {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.8125rem;
  padding: 0.4rem 0.95rem 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
}

body.v3 .badge {
  font-family: var(--font-sans);
  font-weight: 600;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
}

/* --------------------------------------------------------------------------
   Inputs
   -------------------------------------------------------------------------- */
body.v3 .input-field {
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  padding: 0.6rem 0.85rem;
  height: 40px;
  font-family: var(--font-sans);
}

body.v3 textarea.input-field { height: auto; }

body.v3 .input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

/* --------------------------------------------------------------------------
   Page header
   -------------------------------------------------------------------------- */
body.v3 .page-header h1 {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.625rem;
  letter-spacing: -0.025em;
  color: var(--ink);
}

body.v3 .page-header p {
  font-size: 0.875rem;
  color: var(--ink-faint);
  font-weight: 500;
}

body.v3 .page-shell {
  padding-top: 1.5rem;
}

/* --------------------------------------------------------------------------
   Feature card (banner principal de conexión)
   -------------------------------------------------------------------------- */
body.v3 .feature-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

/* acento decorativo discreto en la esquina del feature card */
body.v3 .feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-soft) 100%);
  opacity: 0.85;
}

body.v3 .feature-card-headline {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.018em;
  color: var(--ink);
}

body.v3 .feature-card-help {
  font-size: 0.8125rem;
  color: var(--ink-soft);
  margin-top: 0.3rem;
  line-height: 1.5;
  font-weight: 500;
}

/* fila de acciones secundarias */
body.v3 .secondary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 1.25rem;
  margin-top: 1.25rem;
  border-top: 1px solid var(--hairline);
  align-items: center;
}

body.v3 .secondary-actions-label {
  font-size: 0.75rem;
  color: var(--ink-faint);
  margin-right: 0.5rem;
  font-weight: 600;
}

body.v3 .empty-frame {
  background: var(--surface-soft);
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--radius-md);
}

body.v3 .text-tabular {
  font-variant-numeric: tabular-nums;
}

body.v3 .admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.45rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xs);
}

body.v3 .admin-tab {
  min-height: 40px;
  padding: 0.6rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--ink-soft);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

body.v3 .admin-tab:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

body.v3 .admin-tab[aria-selected='true'] {
  color: var(--accent-strong);
  background: var(--accent-tint);
  border-color: color-mix(in srgb, var(--accent) 22%, transparent);
}

body.v3 .admin-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.v3 .admin-mobile-bottom-nav,
body.v3 .admin-mobile-card-list {
  display: none;
}

body.v3 .admin-mobile-tenant-card {
  padding: 1rem;
  border: 1px solid var(--hairline);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

body.v3 .admin-mobile-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

body.v3 .admin-mobile-card-head strong {
  display: block;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.25;
}

body.v3 .admin-mobile-card-head p {
  margin-top: 0.2rem;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  word-break: break-all;
}

body.v3 .admin-mobile-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.85rem;
}

body.v3 .admin-mobile-metrics > span {
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  background: var(--surface-sunk);
  color: var(--ink-soft);
  font-size: 0.75rem;
  line-height: 1.35;
}

body.v3 .admin-mobile-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.85rem;
}

body.v3 .admin-passkey-card {
  border-color: color-mix(in srgb, var(--accent) 22%, var(--hairline));
}

body.v3 .admin-passkey-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-strong) 76%, transparent);
}

body.v3 {
  background-image: none !important;
}

/* --------------------------------------------------------------------------
   Local utility layer used by the tenant dashboard pages.
   Replaces Tailwind runtime classes without compiling CSS in the browser.
   `.hidden` is declared after the display utilities so a class list like
   `flex hidden` resolves to display:none by source order, without using
   !important — so Tailwind CDN's responsive `.lg:flex` (loaded later on
   pages like /login) can still win on large screens.
   -------------------------------------------------------------------------- */
.block { display: block; }
.inline-flex { display: inline-flex; }
.flex { display: flex; }
.grid { display: grid; }
.hidden { display: none; }
.flex-1 { flex: 1 1 0%; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-baseline { align-items: baseline; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.overflow-hidden { overflow: hidden; }
.min-w-0 { min-width: 0; }
.min-h-screen { min-height: 100vh; }
.h-1 { height: 0.25rem; }
.h-full { height: 100%; }
.w-fit { width: fit-content; }
.w-full { width: 100%; }
.max-w-full { max-width: 100%; }
.max-w-2xl { max-width: 42rem; }
.min-h-\[220px\] { min-height: 220px; }
.rounded-full { border-radius: 9999px; }

.gap-1 { gap: 0.25rem; }
.gap-1\.5 { gap: 0.375rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }
.gap-6 { gap: 1.5rem; }

.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.col-span-2 { grid-column: span 2 / span 2; }

.text-center { text-align: center; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.font-medium { font-weight: 500; }
.font-mono { font-family: var(--font-mono, ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace); }

@media (min-width: 640px) {
  .sm\:flex-row { flex-direction: row; }
  .sm\:flex-col { flex-direction: column; }
  .sm\:items-start { align-items: flex-start; }
  .sm\:justify-between { justify-content: space-between; }
  .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm\:col-span-2 { grid-column: span 2 / span 2; }
}

@media (min-width: 768px) {
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md\:col-span-2 { grid-column: span 2 / span 2; }
}

@media (min-width: 1024px) {
  .lg\:flex-row { flex-direction: row; }
  .lg\:items-start { align-items: flex-start; }
  .lg\:items-center { align-items: center; }
  .lg\:items-end { align-items: flex-end; }
  .lg\:justify-between { justify-content: space-between; }
  .lg\:justify-end { justify-content: flex-end; }
  .lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lg\:grid-cols-\[1\.4fr_1fr\] { grid-template-columns: 1.4fr 1fr; }
  .lg\:grid-cols-\[1fr_1fr_2fr_auto\] { grid-template-columns: 1fr 1fr 2fr auto; }
  .lg\:col-span-2 { grid-column: span 2 / span 2; }
  .lg\:col-span-3 { grid-column: span 3 / span 3; }
  .lg\:p-7 { padding: 1.75rem; }
  .lg\:p-10 { padding: 2.5rem; }
  .lg\:w-auto { width: auto; }
}

/* --------------------------------------------------------------------------
   Mobile app shell — tenant panel as a simple touch-first app.
   -------------------------------------------------------------------------- */
.shrink-0 { flex-shrink: 0; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.v3 .mobile-bottom-nav { display: none; }

body.v3 .app-home-shell {
  max-width: 58rem;
}

body.v3 .app-hero {
  max-width: 44rem;
}

body.v3 .app-hero-row {
  max-width: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

body.v3 .app-header-status {
  flex-shrink: 0;
  padding-top: 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

body.v3 .app-connect-button {
  width: auto;
  min-width: 96px;
}

@media (max-width: 767px) {
  html,
  body.v3 {
    width: 100%;
    max-width: 100%;
  }

  body.v3 {
    background: var(--bg);
    overflow-x: hidden;
    min-height: 100svh;
  }

  body.v3 .topbar {
    border-bottom: 1px solid color-mix(in srgb, var(--hairline) 82%, transparent);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
  }

  body.v3 .topbar-inner {
    min-height: 58px;
    gap: 0.55rem;
    padding: calc(0.55rem + env(safe-area-inset-top)) 0.75rem 0.55rem;
  }

  body.v3 .topbar-brand {
    min-width: 0;
    flex: 1;
  }

  body.v3 .topbar-brand-name {
    font-size: 1rem;
  }

  body.v3 .topbar-brand-tag,
  body.v3 .topbar-nav {
    display: none;
  }

  body.v3 .topbar-actions {
    gap: 0.3rem;
    flex-shrink: 0;
  }

  body.v3 .topbar-tenant {
    max-width: 118px;
    padding: 0.28rem 0.42rem 0.28rem 0.34rem;
  }

  body.v3 .topbar-tenant span[style*='flex-direction:column'] {
    min-width: 0;
  }

  body.v3 .topbar-tenant span[style*='font-size:0.78rem'] {
    max-width: 62px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.v3 .icon-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 14px;
    background: var(--surface-soft);
  }

  body.v3 .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: block;
    padding: 0.4rem max(0.55rem, env(safe-area-inset-left)) calc(0.4rem + env(safe-area-inset-bottom)) max(0.55rem, env(safe-area-inset-right));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-top: 1px solid var(--hairline);
    box-shadow: 0 -14px 34px rgba(15, 23, 42, 0.08);
    backdrop-filter: saturate(150%) blur(14px);
    -webkit-backdrop-filter: saturate(150%) blur(14px);
  }

  body.v3 .mobile-bottom-nav-inner {
    display: flex;
    gap: 0.2rem;
    max-width: 460px;
    margin: 0 auto;
  }

  body.v3 .mobile-nav-link {
    flex: 1 1 0;
    min-width: 0;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    border-radius: 16px;
    color: var(--ink-faint);
    text-decoration: none;
    font-size: clamp(0.58rem, 2.6vw, 0.68rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.01em;
    transition: background 150ms ease, color 150ms ease, transform 120ms ease;
  }

  body.v3 .mobile-nav-link svg {
    width: 20px;
    height: 20px;
  }

  body.v3 .mobile-nav-link[aria-current='page'] {
    background: var(--accent-tint);
    color: var(--accent-strong);
  }

  body.v3 .mobile-nav-link:active {
    transform: translateY(1px) scale(0.98);
  }

  body.v3 .page-shell {
    width: 100%;
    max-width: 100%;
    padding: 0.95rem max(0.82rem, env(safe-area-inset-left)) calc(6.6rem + env(safe-area-inset-bottom)) max(0.82rem, env(safe-area-inset-right));
  }

  body.v3 .app-home-shell {
    max-width: 100%;
  }

  body.v3 .app-hero-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  body.v3 .app-header-status {
    padding-top: 0;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  body.v3 .app-header-status .status-pill {
    width: fit-content;
    max-width: 100%;
  }

  body.v3 .app-connect-button {
    width: auto;
    min-width: 104px;
  }

  body.v3 .display-xl { font-size: 2rem; }
  body.v3 .display-lg { font-size: 1.55rem; line-height: 1.12; }
  body.v3 .display-md { font-size: 1.18rem; }
  body.v3 .display-sm { font-size: 1rem; }
  body.v3 .page-header h1 { font-size: 1.55rem; }

  body.v3 header.mb-8 { margin-bottom: 1.25rem; }
  body.v3 .mb-8 { margin-bottom: 1.25rem; }
  body.v3 .mt-6 { margin-top: 1rem; }

  body.v3 .surface-card,
  body.v3 .feature-card {
    border-radius: 18px;
  }

  body.v3 .surface-card.p-6,
  body.v3 .surface-card.p-7,
  body.v3 .feature-card,
  body.v3 .p-6,
  body.v3 .p-5 {
    padding: 1rem;
  }

  body.v3 .stat-tile {
    padding: 0.95rem 1rem;
  }

  body.v3 .stat-tile-value {
    font-size: 1.55rem;
  }

  body.v3 .btn,
  body.v3 .btn-accent,
  body.v3 button.btn,
  body.v3 a.btn {
    min-height: 48px;
    height: auto;
    width: 100%;
    justify-content: center;
    padding: 0.78rem 1rem;
    border-radius: 14px;
    white-space: normal;
  }

  body.v3 .btn-sm {
    min-height: 42px;
    padding: 0.65rem 0.85rem;
  }

  body.v3 .btn-accent {
    min-width: 0;
  }

  body.v3 .w-fit {
    width: 100%;
  }

  body.v3 .input-field {
    min-height: 48px;
    height: auto;
    font-size: 1rem;
  }

  body.v3 textarea.input-field {
    min-height: 112px;
  }

  body.v3 .secondary-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  body.v3 .secondary-actions-label {
    margin: 0;
  }

  body.v3 .grid,
  body.v3 .lg\:grid-cols-2,
  body.v3 .lg\:grid-cols-3,
  body.v3 .lg\:grid-cols-4,
  body.v3 .lg\:grid-cols-\[1\.4fr_1fr\],
  body.v3 .lg\:grid-cols-\[1fr_1fr_2fr_auto\],
  body.v3 .md\:grid-cols-2,
  body.v3 .sm\:grid-cols-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  body.v3 section.grid.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.v3 .lg\:col-span-2,
  body.v3 .lg\:col-span-3,
  body.v3 .md\:col-span-2,
  body.v3 .sm\:col-span-2,
  body.v3 .col-span-2 {
    grid-column: auto;
  }

  body.v3 .flex.lg\:flex-row,
  body.v3 .flex.sm\:flex-row,
  body.v3 .mobile-stack {
    flex-direction: column;
    align-items: stretch;
  }

  body.v3 .mobile-actions,
  body.v3 .flex.mobile-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    gap: 0.55rem;
  }

  body.v3 .mobile-actions-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 0.55rem;
  }

  body.v3 .mobile-actions-2 > .btn:first-child {
    grid-column: 1 / -1;
  }

  body.v3 .surface-sunk,
  body.v3 .empty-frame {
    border-radius: 16px;
  }

  body.v3 .min-h-\[220px\] {
    min-height: 180px;
  }

  body.v3 [id='qr-container'] svg {
    max-width: 220px;
    height: auto;
  }

  body.v3 .badge {
    min-height: 26px;
    align-items: center;
  }
}

@media (max-width: 380px) {
  body.v3 .mobile-nav-link {
    font-size: 0.6rem;
  }

  body.v3 .mobile-nav-link svg {
    width: 18px;
    height: 18px;
  }

  body.v3 .topbar-tenant {
    display: none;
  }
}

@media (min-width: 381px) and (max-width: 430px) {
  body.v3 .topbar-tenant span[style*='font-size:0.65rem'] {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Operational client flow: modals, followup previews and WhatsApp QR.
   -------------------------------------------------------------------------- */
body.v3 .modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

body.v3 .modal-panel {
  width: min(100%, 680px);
  max-height: min(88dvh, 760px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
  overflow: hidden;
}

body.v3 .modal-panel-sm { width: min(100%, 420px); }
body.v3 .modal-panel-lg { width: min(100%, 920px); }

body.v3 .modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid var(--hairline);
}

body.v3 .modal-body {
  padding: 1.25rem;
  overflow: auto;
}

body.v3 .client-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 1rem;
}

body.v3 .followup-preview-card {
  padding: 1rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
}

body.v3 .summary-tool-card {
  display: block;
  padding: 1rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  color: var(--ink);
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 120ms ease;
}

body.v3 .summary-tool-card:hover {
  border-color: var(--accent-soft);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

body.v3 .summary-tool-card strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
}

body.v3 .summary-tool-card span {
  display: block;
  margin-top: 0.35rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.45;
}

body.v3 .summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: flex-end;
}

body.v3 .cs-mini-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
}

body.v3 .cs-mini-card strong {
  display: block;
  color: var(--ink);
  font-size: 0.92rem;
}

body.v3 .cs-mini-card p {
  margin-top: 0.25rem;
  color: var(--ink-faint);
  font-size: 0.8rem;
  line-height: 1.4;
}

body.v3.admin-body .admin-tabs {
  position: sticky;
  top: 70px;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

body.v3 .client-card-clickable {
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 120ms ease;
}

body.v3 .client-card-clickable:hover {
  border-color: var(--hairline-strong);
  box-shadow: var(--shadow-sm);
}

body.v3 .client-card-clickable:active {
  transform: translateY(1px);
}

body.v3 .client-card-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

body.v3 .followup-day-row {
  display: flex;
  align-items: end;
  gap: 0.75rem;
}

body.v3 .followup-day-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

body.v3 .followup-day-control input {
  max-width: 120px;
}

@media (max-width: 767px) {
  body.v3 .followup-day-row,
  body.v3 .followup-day-control {
    align-items: stretch;
    flex-direction: column;
  }

  body.v3 .followup-day-control input {
    max-width: none;
  }
}

body.v3 .whatsapp-qr-frame {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 0.85rem;
  border: 1px solid var(--hairline);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}

body.v3 .whatsapp-qr-frame svg {
  display: block;
  width: min(72vw, 300px);
  height: auto;
}

body.v3 .guide-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

body.v3 .guide-panel {
  position: relative;
  width: min(760px, 100%);
  max-height: min(86dvh, 760px);
  overflow: auto;
  padding: 1.25rem;
  border: 1px solid var(--hairline);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(14, 165, 233, 0.10), transparent 38%),
    var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

body.v3 .guide-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 34px;
  height: 34px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-weight: 700;
}

body.v3 .guide-kicker {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 700;
}

body.v3 .guide-title {
  max-width: 560px;
  margin-top: 0.9rem;
  font-family: var(--font-sans);
  font-size: clamp(1.75rem, 5vw, 2.7rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

body.v3 .guide-intro {
  max-width: 600px;
  margin-top: 0.8rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.6;
}

body.v3 .guide-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1.25rem;
}

body.v3 .guide-step {
  min-height: 150px;
  padding: 1rem;
  border: 1px solid var(--hairline);
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface-soft) 86%, transparent);
}

body.v3 .guide-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: var(--action);
  color: var(--action-on);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
}

body.v3 .guide-step h3 {
  margin-top: 0.8rem;
  font-size: 1rem;
  font-weight: 800;
}

body.v3 .guide-step p {
  margin-top: 0.4rem;
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.5;
}

body.v3 .guide-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

@media (max-width: 767px) {
  body.v3 .modal-backdrop {
    align-items: flex-end;
    padding: 0.7rem max(0.7rem, env(safe-area-inset-right)) calc(0.7rem + env(safe-area-inset-bottom)) max(0.7rem, env(safe-area-inset-left));
  }

  body.v3 .modal-panel {
    width: 100%;
    max-height: calc(92dvh - env(safe-area-inset-bottom));
    border-radius: 24px 24px 18px 18px;
  }

  body.v3 .modal-header,
  body.v3 .modal-body {
    padding: 1rem;
  }

  body.v3 .client-detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  body.v3 .guide-backdrop {
    align-items: flex-end;
    padding: 0.75rem max(0.75rem, env(safe-area-inset-right)) calc(0.75rem + env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  }

  body.v3 .guide-panel {
    border-radius: 26px 26px 18px 18px;
    max-height: calc(92dvh - env(safe-area-inset-bottom));
  }

  body.v3 .guide-steps {
    grid-template-columns: minmax(0, 1fr);
  }

  body.v3 .guide-step {
    min-height: auto;
  }

  body.v3 .guide-actions .btn {
    width: 100%;
  }

  body.v3 .summary-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  body.v3 .cs-mini-card {
    align-items: stretch;
    flex-direction: column;
  }

  body.v3.admin-body {
    padding-bottom: calc(5.75rem + env(safe-area-inset-bottom));
  }

  body.v3.admin-body .page-shell {
    padding-top: 1rem;
  }

  body.v3.admin-body main > header {
    margin-bottom: 1rem !important;
  }

  body.v3.admin-body main > header h1 {
    font-size: 1.35rem;
  }

  body.v3.admin-body main > header p {
    max-width: 18rem;
  }

  body.v3.admin-body .topbar-actions {
    gap: 0.35rem;
  }

  body.v3.admin-body .topbar-actions .btn[href='/login'] {
    display: none;
  }

  body.v3.admin-body #admin-logout-button {
    padding: 0.5rem 0.65rem;
    font-size: 0.75rem;
  }

  body.v3.admin-body .admin-tabs {
    display: none;
  }

  body.v3.admin-body .admin-mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    display: flex;
    gap: 0.35rem;
    padding: 0.55rem max(0.65rem, env(safe-area-inset-right)) calc(0.55rem + env(safe-area-inset-bottom)) max(0.65rem, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-top: 1px solid var(--hairline);
    box-shadow: 0 -12px 32px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  body.v3.admin-body .admin-mobile-nav-link {
    flex: 1;
    min-width: 0;
    min-height: 48px;
    display: grid;
    place-items: center;
    gap: 0.18rem;
    padding: 0.42rem 0.2rem;
    border: 0;
    border-radius: 18px;
    background: transparent;
    color: var(--ink-faint);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.1;
    transition: transform 160ms ease, background 160ms ease, color 160ms ease;
    -webkit-tap-highlight-color: transparent;
  }

  body.v3.admin-body .admin-mobile-nav-link svg {
    width: 21px;
    height: 21px;
    fill: currentColor;
  }

  body.v3.admin-body .admin-mobile-nav-link:active {
    transform: scale(0.96);
  }

  body.v3.admin-body .admin-mobile-nav-link[aria-selected='true'] {
    background: var(--accent-tint);
    color: var(--accent-strong);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
  }

  body.v3.admin-body .data-table,
  body.v3.admin-body .data-table + * {
    display: none;
  }

  body.v3.admin-body .admin-mobile-card-list {
    display: grid;
    gap: 0.75rem;
    padding: 0.85rem;
  }

  body.v3.admin-body .surface-card.p-0 > div[style*='overflow-x'] {
    display: none;
  }

  body.v3.admin-body .stat-tile {
    padding: 1rem;
  }

  body.v3.admin-body .stat-tile-value {
    font-size: 1.45rem;
  }

  body.v3.admin-body .admin-tab-panel.space-y-6,
  body.v3.admin-body #admin-panel.space-y-6 {
    row-gap: 0.9rem;
  }

  body.v3.admin-body .surface-card.p-5,
  body.v3.admin-body .surface-card.p-6,
  body.v3.admin-body .surface-card.lg\:p-6,
  body.v3.admin-body .surface-card.lg\:p-7 {
    padding: 1rem;
  }

  body.v3.admin-body #admin-tenants .surface-card .lg\:items-end,
  body.v3.admin-body #admin-tenants .surface-card .lg\:flex-col {
    align-items: stretch;
    flex-direction: column;
  }

  body.v3.admin-body #admin-tenants .surface-card button {
    width: 100%;
  }
}
