/* ==========================================================================
   Leads — design tokens (the Analíticas design system, same as Buzón)
   Geist type, flat layered surfaces with hairline borders, one ink color
   and one accent. No gradients.
   ========================================================================== */
:root {
  --bg: #f6f6f7;
  --bg-soft: #fafafa;
  --bg-sunken: #f0f0f2;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --raised: #ffffff;
  --border: rgba(15, 15, 20, .07);
  --border-strong: rgba(15, 15, 20, .12);
  --border-3: rgba(15, 15, 20, .2);
  --text: #0b0b0f;
  --text-2: #55555e;
  --text-3: #8c8c96;
  --grid: #ececef;
  --primary: #2a78d6;
  --primary-hover: #256abf;
  --primary-soft: rgba(42, 120, 214, .09);
  --primary-ink: #1c5cab;
  --on-primary: #ffffff;
  --success: #067a3a;
  --success-soft: rgba(12, 163, 12, .1);
  --warning: #9a6200;
  --warning-soft: rgba(250, 178, 25, .14);
  --warning-border: transparent;
  --danger: #d03b3b;
  --danger-soft: rgba(208, 59, 59, .09);
  --violet: #6250d6;
  --violet-soft: rgba(98, 80, 214, .11);
  --teal: #1baf7a;
  --teal-soft: rgba(27, 175, 122, .12);
  --star: #f5a623;
  --unread-bg: rgba(42, 120, 214, .035);
  --selected-bg: rgba(15, 15, 20, .05);
  --shadow-sm: 0 1px 2px rgba(15, 15, 20, .04);
  --shadow: 0 1px 2px rgba(15, 15, 20, .04), 0 12px 32px -20px rgba(15, 15, 20, .25);
  --shadow-lg: 0 40px 100px -30px rgba(15, 15, 20, .35), 0 2px 8px rgba(15, 15, 20, .06);
  --chart-a: #2a78d6;
  --chart-b: #1baf7a;
  --radius: 20px;
  --radius-sm: 12px;
  --sidebar-w: 268px;
  --list-w: 400px;
  --font: 'Geist', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #08090b;
    --bg-soft: #15161a;
    --bg-sunken: #1c1d22;
    --surface: #111215;
    --surface-2: #15161a;
    --raised: #18191d;
    --border: rgba(255, 255, 255, .065);
    --border-strong: rgba(255, 255, 255, .11);
    --border-3: rgba(255, 255, 255, .2);
    --text: #f2f2f4;
    --text-2: #b4b4bd;
    --text-3: #7b7b86;
    --grid: #1e1f24;
    --primary: #4f8cff;
    --primary-hover: #6b9dff;
    --primary-soft: rgba(79, 140, 255, .14);
    --primary-ink: #9ec0ff;
    --success: #2bd46b;
    --success-soft: rgba(43, 212, 107, .12);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, .12);
    --warning-border: transparent;
    --danger: #ff6b6b;
    --danger-soft: rgba(255, 107, 107, .12);
    --violet: #9085e9;
    --violet-soft: rgba(144, 133, 233, .14);
    --teal: #199e70;
    --teal-soft: rgba(25, 158, 112, .14);
    --unread-bg: rgba(79, 140, 255, .045);
    --selected-bg: rgba(255, 255, 255, .06);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 16px 40px -24px rgba(0, 0, 0, .9);
    --shadow-lg: 0 40px 120px -30px rgba(0, 0, 0, .95), 0 0 0 1px rgba(255, 255, 255, .04);
    --chart-a: #3987e5;
    --chart-b: #199e70;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #08090b;
  --bg-soft: #15161a;
  --bg-sunken: #1c1d22;
  --surface: #111215;
  --surface-2: #15161a;
  --raised: #18191d;
  --border: rgba(255, 255, 255, .065);
  --border-strong: rgba(255, 255, 255, .11);
  --border-3: rgba(255, 255, 255, .2);
  --text: #f2f2f4;
  --text-2: #b4b4bd;
  --text-3: #7b7b86;
  --grid: #1e1f24;
  --primary: #4f8cff;
  --primary-hover: #6b9dff;
  --primary-soft: rgba(79, 140, 255, .14);
  --primary-ink: #9ec0ff;
  --success: #2bd46b;
  --success-soft: rgba(43, 212, 107, .12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, .12);
  --warning-border: transparent;
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, .12);
  --violet: #9085e9;
  --violet-soft: rgba(144, 133, 233, .14);
  --teal: #199e70;
  --teal-soft: rgba(25, 158, 112, .14);
  --unread-bg: rgba(79, 140, 255, .045);
  --selected-bg: rgba(255, 255, 255, .06);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 16px 40px -24px rgba(0, 0, 0, .9);
  --shadow-lg: 0 40px 120px -30px rgba(0, 0, 0, .95), 0 0 0 1px rgba(255, 255, 255, .04);
  --chart-a: #3987e5;
  --chart-b: #199e70;
  color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -.003em;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }
svg.i.lg { width: 22px; height: 22px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 8px; }
::selection { background: var(--primary-soft); }
kbd { font-family: var(--font); font-size: 11px; font-weight: 600; color: var(--text-3); padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface); }

/* ==========================================================================
   Shell
   ========================================================================== */
.app { display: flex; height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--surface) 72%, var(--bg));
  border-right: 1px solid var(--border);
  transition: width .25s var(--ease), transform .25s var(--ease);
  position: relative;
  z-index: 30;
}
.app.collapsed .sidebar { width: 76px; }
.app.collapsed .sidebar .hide-collapsed { display: none !important; }
.app.collapsed .nav-item { justify-content: center; padding: 10px; }
.app.collapsed .brand { justify-content: center; padding-inline: 0; }
.app.collapsed .compose-btn { padding: 0; width: 44px; margin-inline: auto; }

.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 22px 14px;
}
.brand-logo { width: 32px; height: 32px; border-radius: 10px; flex: none; box-shadow: 0 0 0 1px var(--border-strong); }
.brand-name { font-weight: 650; font-size: 16px; letter-spacing: -.02em; line-height: 1.2; }
.brand-sub { font-size: 11px; font-weight: 500; letter-spacing: .08em; color: var(--text-3); margin-top: 1px; }

.collapse-btn {
  position: absolute; top: 60px; right: -13px;
  width: 26px; height: 26px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface);
  display: grid; place-items: center; color: var(--text-3);
  box-shadow: var(--shadow-sm); z-index: 2;
}
.collapse-btn:hover { color: var(--text); }
.app.collapsed .collapse-btn svg { transform: rotate(180deg); }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 6px 14px 12px; scrollbar-width: none; }
.sidebar-scroll::-webkit-scrollbar { display: none; }
.compose-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 40px; border-radius: 11px;
  background: var(--text); color: var(--bg); font-weight: 550; font-size: 13.5px;
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .15);
  transition: opacity .15s, transform .08s;
  margin-bottom: 10px;
}
.compose-btn:hover { opacity: .88; }
.compose-btn:active { transform: translateY(1px); }

.nav-section { margin-top: 18px; }
.nav-label {
  font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-3); padding: 0 10px 6px;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 36px; padding: 7px 10px; border-radius: 10px; gap: 11px;
  color: var(--text-2); font-weight: 500; text-align: left;
  position: relative; transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-item:hover { background: var(--bg-sunken); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border); }
.nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--text);
}
.nav-item .i { color: inherit; }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count {
  font-size: 11.5px; font-weight: 650; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums;
  background: var(--primary-soft); color: var(--primary-ink);
}
.nav-item.active .count, .count.hot { background: var(--primary-soft); color: var(--primary-ink); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.nav-domain { font-weight: 550; }
.nav-edit { font-size: 11.5px; letter-spacing: 0; text-transform: none; font-weight: 600; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.pick-bar {
  position: sticky; top: -32px; z-index: 5; margin: 0 -40px 18px; padding: 14px 40px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.pick-bar .search { flex: 1 1 280px; max-width: 520px; }
.pick-bar .pick-count { font-weight: 700; white-space: nowrap; }
.pick-bar .pick-count small { display: block; font-weight: 500; color: var(--text-2); font-size: 12.5px; }
.pick-bar .grow { flex: 1; }
.pick-section { margin-bottom: 22px; }
.pick-section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pick-section-head h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.pick-section-head .faint { font-size: 13px; }
.pick-section-head .links { margin-left: auto; font-size: 13px; }
.grid.notif { grid-template-columns: minmax(340px, 420px) minmax(0, 1fr); align-items: start; }
@media (max-width: 1024px) { .grid.notif { grid-template-columns: 1fr; } }
.pick-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border); cursor: pointer; transition: border-color .12s, background .12s; min-width: 0;
}
.pick-item:hover { border-color: var(--border-strong); background: var(--bg-soft); }
.pick-item .grow { flex: 1; min-width: 0; }
.pick-item:has(input:not(:checked)) { opacity: .55; }
.nav-domain .chev { margin-left: auto; transition: transform .15s; color: var(--text-3); }
.nav-domain.open .chev { transform: rotate(180deg); }
.nav-mailboxes { padding-left: 10px; display: none; }
.nav-mailboxes.open { display: block; }
.nav-mailboxes .nav-item { padding-block: 7px; font-size: 13.5px; }
.nav-mailboxes .nav-item .label { color: var(--text-2); }
.nav-mailboxes .nav-item.active .label { color: var(--text); }
.nav-mailboxes .nav-item.unread .label { color: var(--text); font-weight: 600; }

.user-card {
  display: flex; align-items: center; gap: 12px;
  margin: 6px 14px 14px; padding: 8px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  text-align: left; width: calc(100% - 28px); transition: border-color .15s;
}
.user-card:hover { border-color: var(--border-strong); }
.user-card .meta { flex: 1; min-width: 0; }
.user-card .name { font-weight: 600; font-size: 13.5px; line-height: 1.25; }
.user-card .email { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  width: 36px; height: 36px; border-radius: 11px; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 650; font-size: 13px;
  background: var(--primary); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
}
.avatar.sm { width: 32px; height: 32px; border-radius: 10px; font-size: 12.5px; }
.avatar.xs { width: 26px; height: 26px; border-radius: 8px; font-size: 11px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.topbar {
  height: 64px; flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(18px) saturate(1.5); -webkit-backdrop-filter: blur(18px) saturate(1.5);
}
.topbar .menu-btn { display: none; }
.search {
  flex: 1; max-width: 560px; position: relative;
}
.search input {
  width: 100%; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-sunken); font-size: 13.5px;
  padding: 0 14px 0 36px; outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
.search input::placeholder { color: var(--text-3); }
.search input:hover { border-color: var(--border-strong); }
.search input:focus { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px var(--primary-soft); }
.search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.search kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); }
.search .palette-hint { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); display: grid; border-radius: 7px; }
.search .palette-hint kbd { position: static; transform: none; cursor: pointer; transition: color .15s, border-color .15s; }
.search .palette-hint:hover kbd { color: var(--text); border-color: var(--border-3); }
.search input { padding-right: 64px; }

/* Command palette */
.palette-back { position: fixed; inset: 0; z-index: 150; background: rgba(0, 0, 0, .4); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; animation: fade .12s; }
.palette { width: min(620px, 100%); border-radius: 18px; background: var(--raised); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .16s var(--ease); }
.palette .q { position: relative; border-bottom: 1px solid var(--border); }
.palette .q .i { position: absolute; left: 19px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.palette input { width: 100%; height: 56px; border: 0; outline: 0; background: transparent; padding: 0 20px 0 50px; font-size: 16px; }
.palette .results { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette .grp { padding: 8px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.palette .res { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border-radius: 11px; text-align: left; color: var(--text); }
.palette .res .i { color: var(--text-2); }
.palette .res.on { background: var(--bg-sunken); }
.palette .res .t { min-width: 0; }
.palette .res .s { margin-left: auto; font-size: 12px; color: var(--text-3); max-width: 45%; flex: none; }
.palette .res kbd { margin-left: auto; }
.palette .res .s + kbd { margin-left: 8px; }
.palette .none { padding: 28px; text-align: center; color: var(--text-3); }
.palette .foot { display: flex; gap: 16px; padding: 9px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }
.palette .foot kbd { margin-right: 4px; }
@media (max-width: 860px) { .palette .foot { display: none; } .palette-back { padding-top: calc(10px + env(safe-area-inset-top)); } }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  display: inline-grid; place-items: center; color: var(--text-2);
  transition: background .15s, color .15s; position: relative;
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--text); }
.icon-btn.active { color: var(--primary); background: var(--primary-soft); }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.live-pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600;
  padding: 5px 11px; border-radius: 999px; color: var(--success); background: var(--success-soft);
}
.live-pill .pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: pulse 2s infinite; }
.live-pill.off { color: var(--text-2); background: var(--bg-sunken); }
.live-pill.off .pulse { animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.view { flex: 1; min-height: 0; overflow: auto; }
/* Pages use the full width of the content area with a consistent gutter;
   no centered max-width column (it left big empty bands on wide screens). */
.page { width: 100%; margin: 0; padding: 28px 32px 64px; }
.page-narrow { max-width: none; }
.mute-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); column-gap: 28px; }
.mute-grid > .row { border-bottom: 1px solid var(--border); }
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(520px, 1fr)); gap: 16px; align-items: start; }
.conn-grid > .card { margin-bottom: 0 !important; }
@media (max-width: 860px) { .conn-grid { grid-template-columns: 1fr; } }

/* ==========================================================================
   Page header / common blocks
   ========================================================================== */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; height: 22px; padding: 0 8px; border-radius: 999px; white-space: nowrap;
  background: var(--bg-sunken); color: var(--text-2); border: 1px solid var(--border);
}
.chip.primary { background: var(--primary-soft); color: var(--primary-ink); border-color: transparent; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; letter-spacing: -.035em; line-height: 1.15; margin: 10px 0 4px; font-weight: 650; }
.page-head p { color: var(--text-2); margin: 0; font-size: 14px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 10px; font-weight: 550; font-size: 13.5px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--text); border-color: transparent; color: var(--bg); box-shadow: 0 6px 16px -8px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .15); }
.btn.primary:hover { opacity: .88; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: transparent; }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--bg-sunken); color: var(--text); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 9px; }
.btn.square { border-radius: 10px; }
.link-btn { color: var(--primary); font-weight: 550; font-size: 13.5px; }
.link-btn:hover { text-decoration: underline; }

.banner {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-radius: 14px; font-size: 13.5px;
  background: var(--warning-soft); border: 1px solid var(--warning-border); color: var(--text);
  margin-bottom: 14px;
}
.banner .i { color: var(--warning); }
.banner b { color: var(--warning); }
.banner.info { background: var(--primary-soft); border-color: transparent; }
.banner.info .i, .banner.info b { color: var(--primary-ink); }
.banner .grow { flex: 1; }
.banner .link-btn { white-space: nowrap; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 16px; padding: 18px 20px 8px; }
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; letter-spacing: -.015em; }
.card-head p { margin: 1px 0 0; color: var(--text-3); font-size: 12.5px; }
.card-body { padding: 4px 20px 16px; }

.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.grid.two { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }

.stat { display: flex; gap: 14px; padding: 16px; align-items: flex-start; border-radius: 16px; box-shadow: var(--shadow-sm); }
.stat-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.stat-icon .i { width: 19px; height: 19px; }
.stat-icon.blue { background: var(--primary-soft); color: var(--primary); }
.stat-icon.teal { background: var(--teal-soft); color: var(--teal); }
.stat-icon.violet { background: var(--violet-soft); color: var(--violet); }
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.amber { background: var(--warning-soft); color: var(--warning); }
.stat-label { color: var(--text-2); font-size: 12.5px; font-weight: 550; }
.stat-value { font-size: 27px; font-weight: 650; letter-spacing: -.04em; line-height: 1.2; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--text-3); }
.card.stat { transition: border-color .2s, box-shadow .2s; }
a.card.stat:hover, button.card.stat:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
button.card.stat { text-align: left; width: 100%; }

.row-list > * + * { border-top: 1px solid var(--border); }
.row {
  display: flex; align-items: center; gap: 14px; padding: 13px 0;
}
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; letter-spacing: -.01em; }
.row .sub { color: var(--text-3); font-size: 12.5px; }
.row-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.row-icon.ok { background: var(--success-soft); color: var(--success); }
.row-icon.warn { background: var(--warning-soft); color: var(--warning); }
.row-icon.info { background: var(--primary-soft); color: var(--primary); }
.row-icon.err { background: var(--danger-soft); color: var(--danger); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.empty { padding: 28px 0; color: var(--text-2); text-align: center; }
.empty-big { padding: 72px 24px; text-align: center; color: var(--text-2); }
.empty-big .art {
  width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 16px;
  display: grid; place-items: center; background: var(--bg-sunken); color: var(--text); border: 1px solid var(--border);
}
.empty-big h3 { color: var(--text); margin: 0 0 6px; font-size: 18px; letter-spacing: -.025em; }

.recent-item { display: flex; gap: 12px; padding: 12px 0; align-items: center; width: 100%; text-align: left; }
.recent-item:hover .title { color: var(--primary); }
.row-list > .recent-item, .row-list > a.row { margin: 0 -20px; padding-left: 20px; padding-right: 20px; width: calc(100% + 40px); transition: background .15s; }
.row-list > .recent-item:hover, .row-list > a.row:hover { background: color-mix(in srgb, var(--bg-sunken) 55%, transparent); }

/* Activity chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 180px; overflow: visible; }
.dash-hero > .card:first-child { display: flex; flex-direction: column; }
.dash-hero > .card:first-child .card-body { flex: 1; display: flex; flex-direction: column; }
.dash-hero #chart { flex: 1; min-height: 220px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { display: inline-block; }

/* ==========================================================================
   Mail
   ========================================================================== */
.mail { display: flex; height: 100%; min-height: 0; }
.list-pane {
  width: var(--list-w); flex: none; display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--border); background: var(--surface);
}
.list-head { padding: 18px 18px 12px; border-bottom: 1px solid var(--border); }
.list-title { display: flex; align-items: center; gap: 10px; }
.list-title h2 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.03em; flex: 1; min-width: 0; }
.list-title .sub { font-size: 12.5px; color: var(--text-3); }
.seg {
  display: flex; gap: 2px; margin-top: 12px; overflow-x: auto; scrollbar-width: none;
  width: fit-content; max-width: 100%; padding: 3px; border-radius: 11px; background: var(--bg-sunken); border: 1px solid var(--border);
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  height: 28px; padding: 0 11px; border-radius: 8px; font-size: 12.5px; font-weight: 550; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex: none; transition: color .15s, background .15s;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.seg button .i { display: none; }
.list-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.msg {
  display: flex; gap: 12px; width: 100%; text-align: left;
  padding: 13px 18px 13px 16px; border-bottom: 1px solid var(--border);
  position: relative; transition: background .12s; border-left: 3px solid transparent;
}
.msg:hover { background: color-mix(in srgb, var(--bg-sunken) 55%, transparent); }
.msg.unread { background: var(--unread-bg); }
.msg.unread::after {
  content: ""; position: absolute; left: 6px; top: 26px; width: 7px; height: 7px; border-radius: 50%; background: var(--primary);
}
.msg.selected { background: var(--selected-bg); border-left-color: var(--text); }
.msg .body { flex: 1; min-width: 0; }
.msg .top { display: flex; align-items: baseline; gap: 8px; }
.msg .from { flex: 1; min-width: 0; font-weight: 500; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.unread .from { font-weight: 650; }
.msg .date { font-size: 12px; color: var(--text-3); flex: none; font-variant-numeric: tabular-nums; }
.msg.unread .date { color: var(--primary); font-weight: 600; }
.msg .subject { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.msg.unread .subject { font-weight: 600; }
.msg .snippet { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin-top: 2px; }
.msg .meta { display: flex; align-items: center; gap: 6px; margin-top: 7px; color: var(--text-3); }
.mb-tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 550;
  padding: 2px 8px 2px 6px; border-radius: 7px; background: var(--bg-sunken); color: var(--text-2); border: 1px solid var(--border);
  max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mb-tag .dot { width: 7px; height: 7px; }
.msg .star { color: var(--star); }
.msg .star svg { fill: currentColor; }
.load-more { padding: 16px; text-align: center; }
.skeleton { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.skeleton div { height: 11px; border-radius: 6px; background: var(--bg-sunken); animation: breathe 1.4s ease-in-out infinite; margin: 7px 0; }
@keyframes breathe { 50% { opacity: .55; } }

.reader-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.reader-empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--text-2); padding: 24px; }
.reader-toolbar {
  display: flex; align-items: center; gap: 4px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface); flex: none;
}
.reader-toolbar .sep { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }
.reader-toolbar .back-btn { display: none; }
.reader-scroll { flex: 1; overflow-y: auto; padding: 26px 30px 40px; }
.reader-card { max-width: 920px; margin: 0 auto; }
.reader-subject { font-size: 22px; font-weight: 650; letter-spacing: -.03em; line-height: 1.3; margin: 0 0 14px; word-break: break-word; }
.reader-from { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.reader-from .grow { flex: 1; min-width: 0; }
.reader-from .name { font-weight: 650; letter-spacing: -.01em; }
.reader-from .addr { color: var(--text-3); font-weight: 400; font-size: 13px; }
.reader-from .to { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.reader-from .when { color: var(--text-3); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.body-frame-wrap {
  background: #fff; border-radius: 16px; border: 1px solid var(--border);
  padding: 22px 24px; box-shadow: var(--shadow); overflow: hidden;
}
.body-frame-wrap iframe { width: 100%; border: 0; display: block; min-height: 60px; background: #fff; }
/* Dark mode: plain mail takes the app's colors (see mountBody); mail with
   its own design keeps the white card. */
.body-frame-wrap.dark, .body-frame-wrap.dark iframe { background: var(--surface); }
.body-frame-wrap.dark { box-shadow: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .body-frame-wrap.plain { background: var(--surface); box-shadow: none; }
  :root:not([data-theme="light"]) .body-frame-wrap.plain .plain-body { color: var(--text); }
}
:root[data-theme="dark"] .body-frame-wrap.plain { background: var(--surface); box-shadow: none; }
:root[data-theme="dark"] .body-frame-wrap.plain .plain-body { color: var(--text); }
.plain-body { white-space: pre-wrap; word-wrap: break-word; font-size: 14.5px; color: #1f2937; }
.remote-banner { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); margin-bottom: 12px; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.remote-banner .grow { flex: 1; }
.attachments { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-top: 16px; }
.att {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 14px;
  border: 1px solid var(--border-strong); background: var(--surface); text-decoration: none; color: var(--text);
  transition: border-color .15s, transform .15s;
}
.att:hover { border-color: color-mix(in srgb, var(--primary) 55%, var(--border-strong)); text-decoration: none; transform: translateY(-1px); }
.att .ficon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-ink); flex: none; font-size: 10px; font-weight: 700; letter-spacing: .02em; }
.att .grow { min-width: 0; flex: 1; }
.att .fname { font-weight: 600; font-size: 13.3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .fsize { font-size: 12px; color: var(--text-2); }
.thread { margin-top: 24px; }
.thread h4 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); margin: 0 0 10px; }
.thread-item {
  display: flex; gap: 12px; align-items: center; padding: 11px 14px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--surface); width: 100%; text-align: left; margin-bottom: 8px; transition: border-color .15s;
}
.thread-item:hover { border-color: var(--border-strong); }
.quick-reply {
  margin-top: 22px; border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface);
  box-shadow: var(--shadow-sm); transition: box-shadow .15s, border-color .15s;
}
.quick-reply:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.quick-reply textarea {
  width: 100%; border: 0; outline: none; resize: none; background: transparent; padding: 16px 18px 6px; min-height: 64px; display: block;
}
.quick-reply .qr-foot { display: flex; align-items: center; gap: 8px; padding: 8px 10px 10px 16px; }
.quick-reply .qr-foot .grow { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-3); }
.cell-main { max-width: 0; width: 100%; } /* lets long addresses ellipsize instead of widening the table */

/* ==========================================================================
   Forms, toggles, tables
   ========================================================================== */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text-2); }
.field small { display: block; color: var(--text-3); font-size: 12.5px; margin-top: 6px; }
.input, select.input, textarea.input {
  width: 100%; height: 40px; border-radius: 11px; border: 1px solid var(--border-strong);
  background: var(--surface); padding: 0 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 32px; background-repeat: no-repeat; background-position: right 11px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238c8c96' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
textarea.input { height: auto; padding: 11px 12px; resize: vertical; line-height: 1.55; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input.mono { font-family: var(--mono); font-size: 13px; }
.form-error { color: var(--danger); font-size: 13.5px; margin: -4px 0 14px; min-height: 0; }
.toggle { position: relative; width: 42px; height: 24px; flex: none; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; border-radius: 999px; background: var(--border-3); transition: background .2s; cursor: pointer; }
.toggle span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.toggle input:checked + span { background: var(--success); }
.toggle input:checked + span::after { transform: translateX(18px); }
.check-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; cursor: pointer; }
.check-row input { width: 17px; height: 17px; accent-color: var(--primary); }
.table { width: 100%; border-collapse: collapse; }
.table { font-size: 13px; }
.table th { text-align: left; font-size: 11.5px; letter-spacing: .02em; color: var(--text-3); font-weight: 550; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--bg-sunken) 55%, transparent); }
.status { display: inline-flex; align-items: center; gap: 5px; height: 22px; font-size: 11.5px; font-weight: 600; padding: 0 8px; border-radius: 999px; white-space: nowrap; }
.status.ok { background: var(--success-soft); color: var(--success); }
.status.warn { background: var(--warning-soft); color: var(--warning); }
.status.err { background: var(--danger-soft); color: var(--danger); }
.status.off { background: var(--bg-sunken); color: var(--text-2); }
.color-input { width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--border); padding: 0; cursor: pointer; background: none; }
.color-input::-webkit-color-swatch-wrapper { padding: 3px; }
.color-input::-webkit-color-swatch { border: 0; border-radius: 6px; }
.steps { margin: 0 0 18px; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 12px; padding: 7px 0; color: var(--text-2); font-size: 14px; }
.steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 8px; background: var(--primary-soft); color: var(--primary-ink); font-weight: 700; font-size: 12.5px; display: grid; place-items: center; flex: none; }
.steps b { color: var(--text); }
.access-domain { border: 1px solid var(--border); border-radius: 12px; padding: 4px 14px; margin-bottom: 10px; }
.access-domain .mbs { padding-left: 27px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); column-gap: 10px; }
.access-domain .mbs .check-row { font-size: 13.5px; }

/* Categorías y reglas */
.cats { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cat-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 999px; font-size: 12.5px; font-weight: 550; color: var(--text-2); background: var(--surface); border: 1px solid var(--border-strong); white-space: nowrap; flex: none; transition: all .15s; }
.cat-chip:hover { color: var(--text); border-color: var(--border-3); }
.cat-chip.on { color: var(--bg); background: var(--text); border-color: transparent; }
.cat-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.cat-personas { background: #2a78d6; } .cat-facturas { background: #1baf7a; } .cat-notificaciones { background: #eda100; } .cat-promociones { background: #e87ba4; }
.organize-card { display: flex; align-items: center; gap: 18px; padding: 20px 24px; }
.organize-card h3 { margin: 0 0 4px; font-size: 15px; font-weight: 650; letter-spacing: -.02em; }
.organize-card p { margin: 0; font-size: 14px; max-width: 760px; }
.organize-card.on { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); }
.toggle.big { width: 52px; height: 30px; }
.toggle.big span::after { width: 24px; height: 24px; }
.toggle.big input:checked + span::after { transform: translateX(22px); }
.sug-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 10px; padding: 16px 26px 22px; }
.sug { min-width: 0; display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 15px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); }
.sug .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sug small { font-size: 12.5px; color: var(--text-2); }
.sug small.faint { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug-actions { display: flex; flex-direction: column; gap: 6px; }
.rule-row.off .title, .rule-row.off .sub { opacity: .5; }
.rule-order { display: flex; flex-direction: column; }
.rule-order .icon-btn { width: 30px; height: 26px; }
.cond-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.cond-row .input { flex: 1; min-width: 0; height: 40px; }
.act-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
select.input.inline { display: inline-block; width: auto; height: 32px; padding: 0 8px; margin: 0 4px; }
.rule-preview { margin-top: 10px; font-size: 13.5px; }
.rule-preview ul { margin: 8px 0 0; padding-left: 18px; color: var(--text-2); }
.rule-preview li { max-width: 100%; }
.rule-preview li .ellipsis { display: block; }
@media (max-width: 860px) {
  .organize-card { flex-wrap: wrap; padding: 16px; }
  .sug-grid { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 16px; }
  .sug { flex-direction: column; align-items: stretch; }
  .sug-actions { flex-direction: row; }
  .sug-actions .btn { flex: 1; }
  .cond-row { flex-wrap: wrap; }
  .cond-row .input { flex: 1 1 40%; }
  .act-grid { grid-template-columns: 1fr; }
}

/* Firma */
.sig-box { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #fff; }
.sig-box .editor-tools { background: var(--surface); border-bottom: 1px solid var(--border); align-items: center; }
.sig-box .editor-tools .btn { width: auto; height: 30px; padding: 0 10px; display: inline-flex; gap: 6px; white-space: nowrap; }
.sig-tool { width: 34px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--text-2); cursor: pointer; }
.sig-tool:hover { background: var(--bg-sunken); color: var(--text); }
.sig-editor { min-height: 140px; max-height: 360px; overflow: auto; padding: 14px 16px; outline: none; color: #1f2937; font: 14px/1.5 Arial, Helvetica, sans-serif; }
.sig-editor:empty::before { content: attr(data-placeholder); color: #9ca3af; }
.sig-editor img { max-width: 100%; cursor: pointer; }
.sig-editor img.sel { outline: 2px solid var(--primary); outline-offset: 2px; }
.sig-editor a { color: #2563eb; }
.sig-img-size { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

/* Envío: spinner y estados */
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: spin .7s linear infinite; flex: none; }
.toast.sending { background: var(--raised); color: var(--text); border: 1px solid var(--border-strong); }
.toast.sent { background: var(--success); color: #fff; }
.toast .i { flex: none; }
.toast.undo { gap: 12px; padding-right: 8px; }
.toast.undo .undo-count { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; background: var(--bg-sunken); color: var(--text-2); }
.toast.undo button { margin-left: 4px; height: 30px; padding: 0 12px; border-radius: 9px; text-decoration: none; font-weight: 600; background: var(--text); color: var(--bg); }

/* Cuentas de correo */
.acct-domains { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.acct-domain {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--border-strong);
  background: var(--surface); text-align: left; transition: border-color .15s, background .15s;
}
.acct-domain:hover { border-color: var(--border-3); }
.acct-domain.on { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.acct-domain span { display: flex; flex-direction: column; }
.acct-domain small { font-size: 12px; color: var(--text-2); }
.acct-picker { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.acct-plan { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; padding: 16px 20px; margin-bottom: 16px; }
.seat-bar { height: 8px; border-radius: 6px; background: var(--bg-sunken); overflow: hidden; margin: 6px 0 4px; }
.seat-bar.sm { height: 6px; }
.seat-bar i { display: block; height: 100%; background: var(--primary); border-radius: 6px; }
.acct-tabs { margin: 0 0 16px; }
.acct-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.acct-head h3 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.025em; }
.acct-head p { margin: 4px 0 0; font-size: 13.5px; max-width: 720px; }
.addr-input { display: flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 11px; overflow: hidden; background: var(--surface); }
.addr-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.addr-input .input { border: 0; box-shadow: none !important; border-radius: 0; }
.addr-input span { padding: 0 14px; color: var(--text-2); white-space: nowrap; background: var(--bg-soft); align-self: stretch; display: flex; align-items: center; border-left: 1px solid var(--border); }
.secret-box { display: grid; gap: 10px; padding: 14px 16px; border-radius: 14px; background: var(--bg-sunken); margin-bottom: 12px; }
.secret-box small { display: block; font-size: 12px; color: var(--text-2); }
.secret-box b { font-size: 15px; word-break: break-all; }
.mono { font-family: var(--mono); }
.log-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.log-filters .input { width: auto; min-width: 170px; height: 38px; }

/* ==========================================================================
   Modals, composer, toasts, menus
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .42); backdrop-filter: blur(4px);
  display: grid; place-items: center; z-index: 100; padding: 20px; animation: fade .15s;
}
.modal {
  width: 100%; max-width: 560px; max-height: calc(100dvh - 40px); overflow: auto;
  background: var(--raised); border: 1px solid var(--border-strong); border-radius: 22px; box-shadow: var(--shadow-lg); animation: pop .2s var(--ease);
}
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px 6px; }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 650; flex: 1; letter-spacing: -.025em; }
.modal-body { padding: 12px 22px 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
@keyframes up { from { transform: translateY(100%); } }
@keyframes dropin { from { opacity: 0; transform: translateY(-12px); } }

.composer {
  position: fixed; right: 24px; bottom: 0; width: 640px; max-width: calc(100vw - 32px);
  height: min(680px, calc(100dvh - 60px)); z-index: 90;
  background: var(--raised); border: 1px solid var(--border-strong); border-bottom: 0;
  border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: slideup .22s var(--ease);
}
.composer.min { height: 52px; overflow: hidden; }
@keyframes slideup { from { transform: translateY(30px); opacity: 0; } }
.composer-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 20px; border-bottom: 1px solid var(--border); cursor: default; }
.composer-head h4 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.02em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-fields { padding: 0 20px; }
.cf-row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); min-height: 46px; padding: 4px 0; }
.cf-row > label { font-size: 12.5px; font-weight: 550; color: var(--text-3); width: 48px; flex: none; }
.cf-row input, .cf-row select { border: 0; outline: none; background: transparent; flex: 1; min-width: 0; height: 36px; }
.cf-row .cc-toggle { font-size: 12.5px; font-weight: 600; color: var(--text-2); padding: 4px 8px; border-radius: 8px; }
.cf-row .cc-toggle:hover { background: var(--bg-sunken); }
/* Searchable dropdown (enhanceSelect) */
.combo-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 10px; margin-left: -10px; border-radius: 10px; text-align: left; color: var(--text); transition: background .15s; }
.combo-btn:hover, .combo-btn[aria-expanded="true"] { background: var(--bg-sunken); }
.combo-btn > .ellipsis { flex: 1; min-width: 0; }
.combo-btn > .i { color: var(--text-3); }
.combo-pop { position: fixed; z-index: 130; display: flex; flex-direction: column; padding: 6px; border-radius: 16px; background: var(--raised); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); animation: pop .16s var(--ease); }
.combo-q { position: relative; flex: none; margin-bottom: 4px; }
.combo-q .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.combo-q input { width: 100%; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-sunken); padding: 0 12px 0 34px; outline: none; }
.combo-q input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.combo-list { overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.combo-list .grp { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.combo-list .opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: 10px; text-align: left; font-size: 13.5px; color: var(--text); }
.combo-list .opt.on { background: var(--bg-sunken); }
.combo-list .opt small { display: block; font-size: 12px; color: var(--text-3); }
.combo-list .opt.sel { font-weight: 600; }
.combo-list .opt > .i { color: var(--primary); flex: none; }
.combo-list .none { padding: 18px; text-align: center; color: var(--text-3); font-size: 13px; }
.recips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.recips input { min-width: 140px; }
.recip { display: inline-flex; align-items: center; gap: 4px; background: var(--primary-soft); color: var(--primary-ink); border-radius: 8px; padding: 3px 4px 3px 9px; font-size: 13px; font-weight: 550; }
.recip.bad { background: var(--danger-soft); color: var(--danger); }
.cf-row { position: relative; }
.recip-suggest {
  position: absolute; top: calc(100% - 2px); left: 58px; right: 0; z-index: 5; max-height: 320px; overflow-y: auto;
  background: var(--raised); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 6px;
}
.recip-suggest button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 10px; min-height: 48px; }
.recip-suggest button.on, .recip-suggest button:hover { background: var(--bg-sunken); }
.recip-suggest .avatar { flex: none; }
.rs-txt { display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; }
.rs-txt b { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-txt span { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recip button { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 5px; }
.recip button:hover { background: rgba(0, 0, 0, .08); }
.editor-tools { display: flex; gap: 2px; padding: 6px 14px; border-bottom: 1px solid var(--border); }
.editor-tools button { width: 34px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--text-2); }
.editor-tools button:hover { background: var(--bg-sunken); color: var(--text); }
.editor-tools .tools-sep { width: 1px; height: 18px; background: var(--border-strong); align-self: center; margin: 0 6px; }
.editor-tools button.tool-text { width: auto; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; font-size: 12.5px; font-weight: 550; }
.editor-tools button.tool-text .i { width: 16px; height: 16px; }
.tpl-editor { min-height: 160px; max-height: 46vh; overflow-y: auto; border: 1px solid var(--border-strong); border-radius: 11px; padding: 12px 14px; background: var(--surface); flex: none; }
.tpl-editor:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.count.err { background: var(--danger-soft); color: var(--danger); }
.editor { flex: 1; overflow-y: auto; padding: 16px 20px; outline: none; line-height: 1.6; word-wrap: break-word; }
.editor:empty::before { content: attr(data-placeholder); color: var(--text-3); }
.editor blockquote, .quote { border-left: 3px solid var(--border-strong); margin: 10px 0 0; padding: 2px 0 2px 14px; color: var(--text-2); }
.editor .sig { color: var(--text-2); }
.editor img { max-width: 100%; }
.composer-atts { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px 8px; }
.composer-atts .att-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 6px 6px 10px; border-radius: 10px; background: var(--bg-sunken); font-size: 12.5px; }
.composer-atts .att-chip button { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; }
.composer-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.composer-foot .grow { flex: 1; font-size: 12px; color: var(--text-3); }
.track-toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 11px; border-radius: 10px;
  font-size: 12.5px; font-weight: 550; color: var(--text-2); border: 1px solid var(--border-strong);
}
.track-toggle:hover:not(:disabled) { color: var(--text); background: var(--bg-sunken); }
.track-toggle.on { color: var(--primary-ink); background: var(--primary-soft); border: 1px solid transparent; }
.track-toggle:disabled { opacity: .45; cursor: not-allowed; }
.track-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; color: var(--text-3); }
.track-badge.seen { color: var(--success); }
.track-banner { display: flex; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 12px; padding: 10px 14px; border-radius: 12px; background: var(--bg-sunken); color: var(--text-2); }
.track-banner.seen { background: var(--success-soft); color: var(--text); }
.track-banner.seen .i { color: var(--success); }
@media (max-width: 860px) { .track-toggle span { display: none; } .composer-foot .hide-sm, .qr-foot .hide-sm, .row .hide-sm { display: none; } .editor-tools .tool-text span { display: none; } }

.menu {
  position: fixed; z-index: 120; min-width: 220px; padding: 6px;
  background: var(--raised); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow-lg);
  animation: pop .16s var(--ease);
}
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 10px; text-align: left; font-size: 13.5px; font-weight: 500; }
.menu button:hover { background: var(--bg-sunken); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 4px; }

#toast-root { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 13px;
  box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 550; animation: pop .2s var(--ease); max-width: min(540px, calc(100vw - 32px));
}
.toast.err { background: var(--danger); color: #fff; }
.toast button { color: inherit; font-weight: 700; text-decoration: underline; margin-left: 6px; }

/* ==========================================================================
   Auth
   ========================================================================== */
.auth {
  min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  position: relative; overflow-x: hidden; overflow-y: auto; isolation: isolate; color: #fff;
  background: #07080b;
}
/* Flat like the rest of the app: the aurora markup stays but is not shown. */
.aurora { display: none; position: fixed; inset: 0; z-index: -2; overflow: hidden; filter: blur(70px) saturate(130%); }
.aurora i { position: absolute; border-radius: 50%; opacity: .75; mix-blend-mode: screen; animation: drift 22s ease-in-out infinite alternate; }
.aurora i:nth-child(1) { width: 55vw; height: 55vw; left: -12vw; top: -18vw; background: #2563eb; }
.aurora i:nth-child(2) { width: 45vw; height: 45vw; right: -10vw; top: 10vh; background: #7c3aed; animation-duration: 26s; animation-delay: -6s; opacity: .55; }
.aurora i:nth-child(3) { width: 40vw; height: 40vw; left: 20vw; bottom: -20vw; background: #0d9488; animation-duration: 30s; animation-delay: -12s; opacity: .6; }
.aurora i:nth-child(4) { width: 25vw; height: 25vw; left: 38vw; top: 30vh; background: #db2777; animation-duration: 24s; animation-delay: -3s; opacity: .14; }
@keyframes drift { 0% { transform: translate(0, 0) scale(1); } 50% { transform: translate(6vw, 4vh) scale(1.12); } 100% { transform: translate(-4vw, 8vh) scale(.95); } }
.auth-grid-bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, .03) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .03) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 75%);
}
@media (prefers-reduced-motion: reduce) { .aurora i, .auth-notif, .auth-preview-row { animation: none !important; } }

.auth-hero { padding: 56px clamp(32px, 6vw, 96px); display: flex; flex-direction: column; justify-content: center; }
.auth-hero .brand { border: 0; padding: 0 0 44px; }
.auth-hero .brand-sub { color: rgba(255, 255, 255, .6); }
.auth .brand-logo { width: 38px; height: 38px; border-radius: 11px; }
.auth-hero h2 { font-size: clamp(36px, 3.6vw, 52px); line-height: 1.06; letter-spacing: -.05em; margin: 0 0 16px; font-weight: 650; }
.auth-hero .grad { color: #9ec0ff; }
.auth-sub { font-size: 16px; line-height: 1.6; color: rgba(255, 255, 255, .62); margin: 0 0 36px; max-width: 460px; }

.auth-stage { position: relative; max-width: 500px; padding-top: 34px; margin-bottom: 30px; }
.auth-notif {
  position: absolute; top: 0; right: -28px; z-index: 2; width: 330px; display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 14px; border-radius: 18px; color: #0f172a;
  background: rgba(255, 255, 255, .86); backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, .55); animation: notifin .6s cubic-bezier(.2, .9, .3, 1.2) both .9s;
}
.auth-notif.in { animation: notifin .6s cubic-bezier(.2, .9, .3, 1.2) both; }
.auth-notif img { width: 38px; height: 38px; border-radius: 10px; flex: none; }
.auth-notif > div { min-width: 0; flex: 1; }
.auth-notif .n-top { display: flex; justify-content: space-between; font-size: 12px; color: #64748b; }
.auth-notif .n-top b { color: #0f172a; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; font-size: 11.5px; }
.auth-notif .n-title { font-weight: 700; font-size: 13.5px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auth-notif .n-body { font-size: 13px; color: #334155; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes notifin { from { opacity: 0; transform: translateY(-14px) scale(.96); } }

.auth-preview {
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .14); border-radius: 22px;
  padding: 10px; backdrop-filter: blur(16px); box-shadow: 0 40px 80px -24px rgba(0, 0, 0, .6);
  transform: perspective(1200px) rotateX(4deg) rotateY(-6deg); transform-origin: left center;
}
.auth-preview-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px 12px; font-size: 13px; }
.auth-preview-head span { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, .25); }
.auth-preview-head span:nth-child(1) { background: #f87171; } .auth-preview-head span:nth-child(2) { background: #fbbf24; } .auth-preview-head span:nth-child(3) { background: #34d399; }
.auth-preview-head b { margin-left: 8px; }
.auth-preview-head em { margin-left: auto; font-style: normal; font-size: 12px; font-weight: 700; background: #f97316; color: #fff; padding: 3px 10px; border-radius: 999px; }
.auth-preview-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 14px; background: rgba(255, 255, 255, .95); color: #0f172a;
  margin-top: 7px; animation: rowin .5s ease both;
}
.auth-preview-row > i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.auth-preview-row > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.auth-preview-row b { font-size: 14px; }
.auth-preview-row span { font-size: 12.5px; color: #475569; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auth-preview-row small { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: #64748b; margin-top: 3px; }
.auth-preview-row small em { width: 6px; height: 6px; border-radius: 50%; }
.auth-preview-row time { font-size: 12px; color: #2563eb; font-weight: 700; align-self: flex-start; }
@keyframes rowin { from { opacity: 0; transform: translateY(10px); } }
.auth-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.auth-chips span {
  display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; padding: 7px 13px; border-radius: 999px;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); color: rgba(255, 255, 255, .88);
}

.auth-side { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px 24px; gap: 18px; }
.auth-card {
  width: 100%; max-width: 440px; padding: 38px 36px 30px; border-radius: 28px;
  background: #111215; border: 1px solid rgba(255, 255, 255, .1);
  box-shadow: 0 40px 120px -30px rgba(0, 0, 0, .95);
  animation: pop .4s ease both;
}
.auth-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; height: 24px; padding: 0 10px; border-radius: 999px; background: rgba(79, 140, 255, .14); color: #9ec0ff; margin-bottom: 16px; }
.auth-card h1 { font-size: 30px; letter-spacing: -.045em; margin: 0 0 8px; font-weight: 650; color: #fff; }
.auth-card p.lead { color: rgba(255, 255, 255, .62); margin: 0 0 26px; font-size: 15px; }
.auth-card .field > span { color: rgba(255, 255, 255, .85); }
.auth-card .input {
  background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .12); color: #fff;
}
.auth-card .input::placeholder { color: rgba(255, 255, 255, .35); }
.auth-card .input:focus { border-color: #4f8cff; background: rgba(255, 255, 255, .09); box-shadow: 0 0 0 4px rgba(79, 140, 255, .2); }
.auth-card .input:-webkit-autofill { -webkit-text-fill-color: #fff; -webkit-box-shadow: 0 0 0 1000px #1b2236 inset; transition: background-color 9999s; }
.auth-card .form-error { color: #fca5a5; }
.auth-submit {
  width: 100%; height: 46px; margin-top: 8px; border-radius: 12px !important; font-size: 14.5px;
  background: #f2f2f4 !important; color: #08090b !important; border: 0 !important;
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, .5) !important; position: relative; overflow: hidden;
}
.auth-submit .i { transition: transform .15s; }
.auth-submit:hover .i { transform: translateX(3px); }
.auth-mobile-brand { display: none; border: 0; padding: 0 0 24px; }
.auth .brand-name { color: #fff; }
.input-icon { position: relative; }
.input-icon > .i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: rgba(255, 255, 255, .4); pointer-events: none; }
.input-icon .input { height: 50px; padding-left: 42px; border-radius: 13px; }
.input-icon:focus-within > .i { color: #9ec0ff; }
.pass-toggle { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; color: rgba(255, 255, 255, .45); }
.pass-toggle:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.auth-foot { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 22px 0 0; font-size: 12.5px; color: rgba(255, 255, 255, .45); }
.auth-copy { font-size: 12px; color: rgba(255, 255, 255, .35); margin: 0; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ==========================================================================
   App en celular: barra de pestañas, gestos, búsqueda (solo ≤ 860px)
   ========================================================================== */
.tabbar, .topbar-brand, .ptr, .swipe-under, .sel-bar, .msg .pick-check { display: none; }

/* Búsqueda (también accesible en escritorio) */
.search-page .big-search { position: relative; margin: 6px 0 18px; }
.search-page .big-search .input { height: 48px; font-size: 16px; padding-left: 44px; border-radius: 14px; }
.search-page .big-search .i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); font-size: 13px; font-weight: 550; color: var(--text-2); background: var(--surface); transition: all .15s; }
.filter-chip:hover { color: var(--text); border-color: var(--border-3); }
.filter-chip.on { color: var(--bg); background: var(--text); border-color: transparent; }
.recent-searches .row { cursor: pointer; }
.active-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.active-filters .filter-chip { height: 30px; font-size: 12.5px; padding: 0 10px; }

/* ==========================================================================
   Responsive
   ========================================================================== */
.scrim { display: none; }
.fab { display: none; }

@media (max-width: 1200px) {
  :root { --list-w: 360px; }
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .grid.two { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-mobile-brand { display: flex; }
  .auth-card { padding: 30px 22px 24px; border-radius: 24px; }
  .aurora i:nth-child(1) { width: 110vw; height: 110vw; }
  .aurora i:nth-child(2) { width: 90vw; height: 90vw; }
  .page { padding: 28px 24px 56px; }
}
/* iOS Safari zooms into any focused field under 16px and leaves the page
   panned sideways; 16px on touch layouts prevents it everywhere. */
@media (max-width: 860px), (pointer: coarse) {
  input, select, textarea, .input, .editor, .cf-row input, .cf-row select, .search input { font-size: 16px !important; }
}
html, body { overflow-x: hidden; max-width: 100%; }

@media (max-width: 860px) {
  body { font-size: 15px; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); box-shadow: var(--shadow-lg);
    width: min(300px, 86vw) !important; padding-top: env(safe-area-inset-top);
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 25; animation: fade .15s; }
  .collapse-btn { display: none; }
  .app.collapsed .sidebar .hide-collapsed { display: revert !important; }
  .topbar { height: auto; min-height: 60px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; gap: 6px; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar .live-pill { display: none; }
  .search kbd { display: none; }
  .search input { height: 40px; }
  .page { padding: 22px 16px calc(88px + env(safe-area-inset-bottom)); }
  .pick-bar { margin: 0 -16px 16px; padding: 12px 16px; top: -22px; }
  .pick-bar { gap: 8px; }
  .pick-bar .pick-count { flex-basis: 100%; }
  .pick-bar .grow { display: none; }
  .pick-bar .btn.primary { margin-left: auto; }
  .pick-bar .search { flex-basis: 100%; max-width: none; order: 3; }
  .pick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pick-item { padding: 10px; gap: 8px; }
  .pick-item .toggle { transform: scale(.85); transform-origin: right center; }
  .page-head { flex-direction: column; align-items: stretch; gap: 4px; }
  .page-head h1 { font-size: 26px; }
  .page-head .actions { padding-top: 6px; }
  .grid.stats { gap: 12px; }
  .stat { padding: 16px; gap: 12px; flex-direction: column; }
  .stat-icon { width: 40px; height: 40px; }
  .stat-value { font-size: 26px; }
  .card-head, .card-body { padding-left: 16px; padding-right: 16px; }
  .row-list > .recent-item, .row-list > a.row { margin: 0 -16px; padding-left: 16px; padding-right: 16px; width: calc(100% + 32px); }
  .card { border-radius: 18px; box-shadow: none; }
  .stat-value { letter-spacing: -.04em; }
  .list-pane { width: 100%; border-right: 0; }
  /* The reader slides over the list (which stays rendered, so its scroll
     position survives), and slides back out when closing. */
  .mail { position: relative; overflow: hidden; }
  .reader-pane {
    display: flex; position: absolute; inset: 0; z-index: 6;
    transform: translateX(100%); visibility: hidden;
    transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .3s;
    box-shadow: -12px 0 30px -18px rgba(0, 0, 0, .6);
  }
  .mail.has-reader .reader-pane { transform: none; visibility: visible; transition: transform .3s cubic-bezier(.2, .8, .2, 1); }
  .reader-pane.dragging { transition: none !important; }
  .reader-toolbar { padding: 8px 8px; overflow-x: auto; }
  .reader-toolbar .back-btn { display: inline-grid; }
  .reader-toolbar .hide-mobile { display: none; }
  .reader-scroll { padding: 18px 14px calc(40px + env(safe-area-inset-bottom)); }
  .reader-subject { font-size: 20px; }
  .body-frame-wrap { padding: 14px; border-radius: 14px; }
  .list-scroll { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .fab {
    display: grid; place-items: center; position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom));
    width: 56px; height: 56px; border-radius: 18px; background: var(--text); color: var(--bg); z-index: 40;
    box-shadow: 0 10px 24px -8px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .15);
  }
  .fab.hidden, .fab.reading { display: none; }
  .composer { right: 0; left: 0; bottom: 0; top: 0; width: 100%; max-width: none; height: 100dvh; border-radius: 0; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .composer.min { top: auto; height: calc(56px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; padding-top: 0; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal, .modal.wide { max-width: none; border-radius: 26px 26px 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); animation: up .32s cubic-bezier(.2, .9, .25, 1); }
  .table .hide-sm { display: none; }
  .quick-reply .qr-foot { flex-wrap: wrap; row-gap: 10px; }
  .quick-reply .qr-foot .grow { flex-basis: 100%; }
  .quick-reply .qr-foot .btn { flex: 1; }
  .kbd-hint { display: none; }
  /* Tables never push the page sideways: they scroll inside their card. */
  .card:has(> .table) { overflow-x: auto !important; }
  .table td, .table th { padding: 10px 8px; }
  #toast-root { bottom: calc(90px + env(safe-area-inset-bottom)); }
}
@media (max-width: 860px) {
  /* Barra de pestañas */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.8) blur(20px); -webkit-backdrop-filter: saturate(1.8) blur(20px);
    border-top: .5px solid var(--border-strong);
  }
  .tabbar a, .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 48px; justify-content: center;
    color: var(--text-3); font-size: 10.5px; font-weight: 600; text-decoration: none; position: relative; border-radius: 12px; transition: color .15s, transform .1s;
  }
  .tabbar a:active, .tabbar button:active { transform: scale(.92); }
  .tabbar .i { width: 24px; height: 24px; stroke-width: 1.9; }
  .tabbar .on { color: var(--primary); }
  .tabbar .on .i { stroke-width: 2.3; }
  .tab-badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg); }
  .tab-badge:empty { display: none; }
  body.reading .tabbar, .app.nav-open .tabbar { display: none; }
  .fab { bottom: calc(76px + env(safe-area-inset-bottom)); }
  #toast-root { top: calc(10px + env(safe-area-inset-top)); bottom: auto; left: 12px; right: 12px; transform: none; flex-direction: column-reverse; }
  #toast-root .toast { width: 100%; max-width: 480px; animation: dropin .22s ease; }
  #toast-root .toast:nth-last-child(n+4) { display: none; }
  .toast.sending { box-shadow: 0 12px 32px -8px rgba(0, 0, 0, .35); }
  .recip-suggest { left: 0; max-height: 46dvh; }
  .list-scroll { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
  .page { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }

  /* Barra superior: logo en lugar del menú y la búsqueda (están abajo) */
  .topbar .menu-btn, .topbar .search { display: none; }
  .topbar-brand { display: flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none !important; font-weight: 650; font-size: 17px; letter-spacing: -.02em; margin-right: auto; }
  .topbar-brand img { width: 30px; height: 30px; border-radius: 9px; box-shadow: 0 0 0 1px var(--border-strong); }

  /* Título grande que se encoge al bajar */
  .list-head h2 { font-size: 30px; font-weight: 700; letter-spacing: -.045em; transition: font-size .18s; }
  .list-head .list-title .sub { transition: opacity .18s; }
  .list-head.compact h2 { font-size: 19px; }
  .list-head.compact .list-title .sub { display: none; }

  /* Jalar para actualizar */
  .list-pane { position: relative; }
  .ptr { display: flex; position: absolute; left: 0; right: 0; justify-content: center; z-index: 3; pointer-events: none; transform: translateY(-50px); opacity: 0; }
  .ptr span { width: 36px; height: 36px; border-radius: 50%; background: var(--raised); border: 1px solid var(--border-strong); display: grid; place-items: center; color: var(--text-2); box-shadow: var(--shadow); }
  .ptr.ready span { background: var(--text); color: var(--bg); }
  .ptr.loading span .i { animation: spin .8s linear infinite; }

  /* Deslizar correos */
  .msg { background: var(--surface); touch-action: pan-y; z-index: 1; }
  .msg.unread { background: linear-gradient(var(--unread-bg), var(--unread-bg)), var(--surface); }
  .msg.selected { background: linear-gradient(var(--selected-bg), var(--selected-bg)), var(--surface); }
  .msg.swiping { transition: none; }
  .msg.snap { transition: transform .22s ease; }
  .swipe-under { display: flex; position: absolute; left: 0; right: 0; z-index: 0; align-items: center; padding: 0 26px; color: #fff; font-weight: 700; font-size: 14px; gap: 8px; }
  .swipe-under.archive { background: #16a34a; justify-content: flex-start; }
  .swipe-under.read { background: #2563eb; justify-content: flex-end; }
  .swipe-under.armed .i { transform: scale(1.25); }
  .swipe-under .i { transition: transform .15s; }
  .list-scroll { position: relative; }

  /* Selección múltiple */
  .msg.picked { background: linear-gradient(var(--selected-bg), var(--selected-bg)), var(--surface); }
  .msg .pick-check { display: none; }
  .selecting .msg .pick-check { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; align-self: center; }
  .selecting .msg.picked .pick-check { background: var(--primary); border-color: var(--primary); color: #fff; }
  .selecting .msg .avatar { display: none; }
  .selecting .msg.unread::after { display: none; }
  .sel-bar { display: none; }
  .selecting .sel-bar { display: flex; align-items: center; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 4; }
  .selecting .sel-bar b { flex: 1; font-size: 15px; }
  .selecting .list-head { display: none; }
  body.selecting-mode .tabbar { display: none; }
  body.selecting-mode .fab { display: none; }

  /* Botones cómodos para el dedo (mínimo 44px) */
  .icon-btn { width: 44px; height: 44px; }
  .reader-toolbar .icon-btn { width: 44px; height: 44px; flex: none; }
  .seg button { height: 34px; padding: 0 13px; }
  .cat-chip { height: 36px; padding: 0 14px; font-size: 13px; }
  .btn.sm { min-height: 40px; }
  .nav-item { min-height: 44px; }
  .toggle { width: 48px; height: 28px; }
  .toggle span::after { width: 22px; height: 22px; }
  .toggle input:checked + span::after { transform: translateX(20px); }
}

@media (max-width: 420px) {
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-sub { display: none; }
}

/* ==========================================================================
   Resumen (the Analíticas home pieces)
   ========================================================================== */
.tnum { font-variant-numeric: tabular-nums; }
.dash .page-head h1 { margin-bottom: 6px; }
.dash .page-head .actions { flex-wrap: nowrap; }
.greet-line { margin: 0 !important; font-size: 19px !important; font-weight: 600; letter-spacing: -.03em; line-height: 1.4; color: var(--text) !important; max-width: 860px; }
.greet-line em { font-style: normal; color: var(--success); }
.greet-line em.warn { color: var(--warning); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  position: relative; overflow: hidden; text-align: left; padding: 16px 16px 0; border-radius: 16px; min-width: 0; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; transition: border-color .2s, box-shadow .2s;
}
.kpi:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); }
.kpi.nospark { padding-bottom: 16px; }
.kpi.warn { border-color: color-mix(in srgb, var(--warning) 35%, var(--border)); }
.kpi .label { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.kpi .value { font-size: 27px; font-weight: 650; letter-spacing: -.04em; line-height: 1.2; margin-top: 10px; }
.kpi .foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; min-height: 20px; }
.kpi .prev { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi .spark { display: block; width: calc(100% + 32px); height: 40px; margin: 10px -16px 0; }
.ch-ic { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; flex: none; color: var(--c, var(--text-2)); background: color-mix(in srgb, var(--c, var(--text-3)) 13%, transparent); }
.ch-ic .i { width: 14px; height: 14px; }
.delta { display: inline-flex; align-items: center; gap: 2px; height: 20px; padding: 0 7px; border-radius: 999px; font-size: 11.5px; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; flex: none; }
.delta.up { color: var(--success); background: var(--success-soft); }
.delta.down { color: var(--danger); background: var(--danger-soft); }
.delta.flat { color: var(--text-3); background: var(--bg-sunken); }
.delta .i { width: 11px; height: 11px; stroke-width: 2.8; }

/* Layout */
.dash-hero { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: stretch; margin-bottom: 16px; }
.dash-row { margin-bottom: 16px; align-items: stretch; }
.dash-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.seg.sm { margin-top: 0; }
.seg.sm button { height: 26px; padding: 0 10px; font-size: 12px; }

/* Chart */
.chart-svg { display: block; overflow: visible; touch-action: pan-y; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .tick { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; font-family: var(--font); }
.chart-svg .hair { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-svg .ring { stroke: var(--surface); stroke-width: 2.5; }
.chart-svg .fade { animation: fadein .7s var(--ease) both; }
@keyframes fadein { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .chart-svg .fade { animation: none; } }
.chart-tip {
  position: fixed; left: 0; top: 0; z-index: 200; pointer-events: none; opacity: 0; min-width: 170px; padding: 10px 12px; border-radius: 13px;
  background: color-mix(in srgb, var(--raised) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); font-size: 12.5px; transition: opacity .12s;
}
.chart-tip.show { opacity: 1; }
.tip-title { color: var(--text-3); font-weight: 550; margin-bottom: 6px; font-size: 12px; }
.tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.75; }
.tip-row strong { margin-left: auto; padding-left: 12px; font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tip-name { color: var(--text-3); }
.tip-key { width: 14px; height: 0; border-top: 2.5px solid var(--c); border-radius: 2px; flex: none; }
.legend i { width: 16px; height: 0; border-radius: 2px; border-top: 2.5px solid var(--c); }
.legend i.box { width: 10px; height: 10px; border: 0; border-radius: 3px; background: color-mix(in srgb, var(--c) 30%, transparent); box-shadow: inset 0 0 0 1.5px var(--c); }

/* Feed (por responder, próximos envíos) */
.feed { display: flex; flex-direction: column; padding: 2px 0 8px; }
.feed-item { display: flex; gap: 12px; padding: 11px 20px; color: var(--text); border-top: 1px solid var(--border); transition: background .15s; align-items: center; }
.feed-item:first-child { border-top: 0; }
.feed-item:hover { background: color-mix(in srgb, var(--bg-sunken) 55%, transparent); text-decoration: none; }
.feed-item .grow { min-width: 0; flex: 1; }
.feed-item .t { font-weight: 600; font-size: 13.5px; letter-spacing: -.01em; }
.feed-item .b { color: var(--text-2); font-size: 12.5px; }
.feed-item .w { font-size: 11.5px; color: var(--text-3); margin-top: 2px; display: flex; align-items: center; }
.feed-item .ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary-ink); }
.feed-item .age { flex: none; font-size: 12px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.feed-item .age.old { color: var(--warning); font-weight: 600; }
.dash-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 28px 24px 30px; color: var(--text-3); font-size: 13px; }
.dash-empty .i { width: 36px; height: 36px; padding: 8px; border-radius: 12px; background: var(--success-soft); color: var(--success); margin-bottom: 6px; }
.dash-empty b { color: var(--text); font-size: 14px; }
.nodata { display: grid; place-items: center; min-height: 150px; color: var(--text-3); font-size: 13px; text-align: center; }

/* Bar list (pendientes por buzón) */
.bars { display: flex; flex-direction: column; padding: 2px 0 10px; }
.bar-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 7px 20px; min-height: 40px; color: var(--text); }
.bar-row:hover { background: color-mix(in srgb, var(--bg-sunken) 55%, transparent); text-decoration: none; }
.bar-row .fill { position: absolute; left: 12px; top: 5px; bottom: 5px; border-radius: 4px 8px 8px 4px; background: color-mix(in srgb, var(--c, var(--chart-a)) 15%, transparent); transform-origin: left; animation: grow .7s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }
.bar-row .k { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; }
.bar-row .k .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.bar-row .v { position: relative; font-weight: 650; letter-spacing: -.01em; }

/* Category split */
.split { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--bg-sunken); }
.split i { display: block; height: 100%; background: var(--c); min-width: 3px; }
.split-legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; margin-top: 18px; }
.split-legend .it { display: flex; align-items: center; gap: 10px; color: var(--text); border-radius: 10px; padding: 4px; margin: -4px; }
.split-legend .it:hover { background: var(--bg-sunken); text-decoration: none; }
.split-legend .it b { font-size: 20px; letter-spacing: -.035em; font-weight: 650; display: block; line-height: 1.1; }
.split-legend .it .s { display: block; font-size: 12px; color: var(--text-3); }
.cmp-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }

/* Weekday × hour heatmap */
.heat-say { margin: 0 0 12px; font-size: 13px; color: var(--text-2); }
.heat-say b { color: var(--text); font-weight: 600; }
.wheat-wrap { overflow-x: auto; scrollbar-width: thin; }
.wheat { display: grid; grid-template-columns: 30px repeat(24, minmax(12px, 1fr)) 34px; gap: 3px; min-width: 520px; align-items: center; }
.wheat .hh { font-size: 10px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.wheat .dd { font-size: 11.5px; color: var(--text-2); font-weight: 550; }
.wheat .tt { font-size: 11px; color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; }
.wheat i, .heat-legend i { display: block; aspect-ratio: 1; border-radius: 4px; background: var(--bg-sunken); }
.wheat i:hover { outline: 1.5px solid var(--text); }
.wheat .s1, .heat-legend .s1 { background: color-mix(in srgb, var(--chart-a) 18%, var(--bg-sunken)); }
.wheat .s2, .heat-legend .s2 { background: color-mix(in srgb, var(--chart-a) 36%, var(--bg-sunken)); }
.wheat .s3, .heat-legend .s3 { background: color-mix(in srgb, var(--chart-a) 56%, var(--bg-sunken)); }
.wheat .s4, .heat-legend .s4 { background: color-mix(in srgb, var(--chart-a) 78%, var(--bg-sunken)); }
.wheat .s5, .heat-legend .s5 { background: var(--chart-a); }
.heat-legend { display: flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 11.5px; color: var(--text-3); margin-top: 10px; }
.heat-legend i { width: 11px; }

@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-hero { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .greet-line { font-size: 17px !important; }
  .kpis { gap: 10px; }
  .kpi { padding: 13px 13px 0; }
  .kpi.nospark { padding-bottom: 13px; }
  .kpi .value { font-size: 23px; }
  .kpi .prev { display: none; }
  .kpi .spark { width: calc(100% + 26px); margin: 8px -13px 0; }
  .feed-item, .bar-row { padding-left: 16px; padding-right: 16px; }
  .bar-row .fill { left: 8px; }
  .dash-tools { width: 100%; justify-content: space-between; }
}

/* ==========================================================================
   Attachment viewer (PDF.js / images)
   ========================================================================== */
body.viewing { overflow: hidden; }
.viewer { position: fixed; inset: 0; z-index: 160; display: flex; flex-direction: column; background: var(--bg); animation: fade .15s; }
.viewer-bar {
  flex: none; display: flex; align-items: center; gap: 6px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(18px) saturate(1.5); -webkit-backdrop-filter: blur(18px) saturate(1.5);
  border-bottom: 1px solid var(--border);
}
.viewer-bar .grow { flex: 1; min-width: 0; padding: 0 6px; }
.viewer-bar .vt { font-weight: 600; font-size: 14px; letter-spacing: -.01em; }
.viewer-bar .vs { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.v-zoom { display: flex; align-items: center; padding: 3px; gap: 2px; border-radius: 11px; background: var(--bg-sunken); border: 1px solid var(--border); margin-right: 4px; }
.v-zoom button { height: 28px; min-width: 30px; padding: 0 8px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.v-zoom button:hover { background: var(--surface); color: var(--text); }
.viewer-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
.v-pages { display: flex; flex-direction: column; align-items: center; gap: 14px; min-width: min-content; }
.v-page { flex: none; background: #fff; border-radius: 4px; box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 8px 24px -12px rgba(0, 0, 0, .35); overflow: hidden; }
.v-page canvas { display: block; width: 100%; height: 100%; }
.viewer-body.zoomed .v-pages { align-items: flex-start; }
.v-img { min-height: 100%; display: grid; place-items: center; }
.v-img img { display: block; max-width: calc(100% * var(--vz, 1)); max-height: calc((100dvh - 120px) * var(--vz, 1)); border-radius: 6px; box-shadow: var(--shadow); cursor: zoom-in; background: var(--surface); }
.viewer-body.zoomed .v-img img { max-width: none; max-height: none; width: calc(100% * var(--vz, 1)); cursor: zoom-out; }
.v-msg { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text-2); text-align: center; }
.v-msg .i { width: 28px; height: 28px; color: var(--warning); }
@media (max-width: 860px) {
  .viewer-bar { padding-left: 6px; padding-right: 6px; gap: 2px; }
  .viewer-bar .hide-mobile { display: none; }
  .v-zoom { display: none; }
  .viewer-body { padding: 10px 8px calc(20px + env(safe-area-inset-bottom)); }
}

/* ==========================================================================
   Leads — conversaciones de WhatsApp
   ========================================================================== */
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 2px var(--surface); flex: none; display: inline-block; }
.online-dot.off { background: var(--border-3); }
.count.warn { background: var(--warning-soft); color: var(--warning); }

/* Lista de conversaciones (reutiliza .msg) */
.msg .assignee { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 550; color: var(--text-2); max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .assignee .avatar { width: 16px; height: 16px; border-radius: 5px; font-size: 8.5px; }
.msg .assignee.none { color: var(--warning); }
.msg .unread-n { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; flex: none; }
.msg .wait { font-size: 11.5px; font-weight: 600; color: var(--warning); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.msg .wait .i { width: 13px; height: 13px; }
.msg .snippet.out::before { content: "Tú: "; color: var(--text-3); }
.st-chip { display: inline-flex; align-items: center; height: 19px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--bg-sunken); color: var(--text-2); }
.st-chip.pending { background: var(--violet-soft); color: var(--violet); }
.st-chip.closed { background: var(--success-soft); color: var(--success); }

/* Encabezado del chat */
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; min-height: 64px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; }
.chat-head .back-btn { display: none; }
.chat-head .who { flex: 1; min-width: 0; text-align: left; border-radius: 10px; padding: 4px 6px; margin-left: -6px; transition: background .15s; }
.chat-head .who:hover { background: var(--bg-sunken); }
.chat-head .who .n { font-weight: 650; letter-spacing: -.015em; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.chat-head .who .s { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chat-head .who .s .dot { width: 7px; height: 7px; }
.assign-btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 6px; border-radius: 11px; border: 1px solid var(--border-strong); background: var(--surface); font-weight: 550; font-size: 13px; max-width: 220px; transition: border-color .15s, background .15s; }
.assign-btn:hover { border-color: var(--border-3); }
.assign-btn .avatar { width: 24px; height: 24px; border-radius: 8px; font-size: 10.5px; }
.assign-btn.none { color: var(--warning); background: var(--warning-soft); border-color: transparent; padding-left: 10px; }
.assign-btn .ellipsis { min-width: 0; }
.chat-notes { display: flex; gap: 8px; align-items: flex-start; padding: 8px 16px; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.chat-notes .i { color: var(--warning); margin-top: 1px; }
.chat-notes span { flex: 1; min-width: 0; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Hilo */
.chat-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 22px 16px; background: var(--bg); }
.chat-thread { max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; }
.chat-older { text-align: center; padding: 4px 0 10px; }
.day { display: flex; justify-content: center; margin: 14px 0 6px; position: sticky; top: -6px; z-index: 2; pointer-events: none; }
.day span { font-size: 11.5px; font-weight: 600; color: var(--text-2); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--border); padding: 3px 11px; border-radius: 999px; box-shadow: var(--shadow-sm); }
.evt { display: flex; justify-content: center; margin: 10px 0; }
.evt span { font-size: 12px; color: var(--text-3); background: var(--bg-sunken); padding: 3px 11px; border-radius: 999px; text-align: center; max-width: 90%; }
.bub-row { display: flex; align-items: flex-end; gap: 6px; margin-top: 10px; }
.bub-row.cont { margin-top: 3px; }
.bub-row.out, .bub-row.note { justify-content: flex-end; }
.bub-row.has-react { margin-bottom: 12px; }
.bub {
  max-width: min(74%, 580px); min-width: 64px; padding: 7px 11px 6px; border-radius: 16px; position: relative;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); word-wrap: break-word; overflow-wrap: anywhere;
}
.bub-row.in .bub { border-bottom-left-radius: 6px; }
.bub-row.in.cont .bub { border-top-left-radius: 6px; }
.bub-row.out .bub { background: color-mix(in srgb, var(--primary) 11%, var(--surface)); border-color: color-mix(in srgb, var(--primary) 14%, transparent); border-bottom-right-radius: 6px; }
.bub-row.out.cont .bub { border-top-right-radius: 6px; }
.bub-row.note .bub { background: var(--warning-soft); border: 1px dashed color-mix(in srgb, var(--warning) 45%, transparent); box-shadow: none; border-bottom-right-radius: 6px; }
.bub-row.failed .bub { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.bub .who { font-size: 11.5px; font-weight: 650; color: var(--text-2); margin-bottom: 2px; display: flex; align-items: center; gap: 5px; }
.bub-row.note .bub .who { color: var(--warning); }
.bub .txt { white-space: pre-wrap; font-size: 14px; line-height: 1.45; }
.bub .txt code { font-family: var(--mono); font-size: 12.5px; background: var(--bg-sunken); padding: 1px 5px; border-radius: 5px; }
.bub .meta { float: right; margin: 6px 0 -3px 12px; font-size: 11px; color: var(--text-3); display: inline-flex; gap: 3px; align-items: center; font-variant-numeric: tabular-nums; position: relative; top: 2px; }
.bub .meta .i { width: 15px; height: 15px; }
.bub .meta.read { color: var(--primary); }
.bub .meta .tk-read { color: var(--primary); }
.bub .meta .tk-failed { color: var(--danger); }
.bub .err { clear: both; display: flex; gap: 8px; align-items: center; color: var(--danger); font-size: 12px; margin-top: 6px; padding-top: 6px; border-top: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }
.bub .err .link-btn { font-size: 12px; color: var(--danger); }
.bub .quote { border-left: 3px solid var(--primary); background: color-mix(in srgb, var(--bg-sunken) 80%, transparent); border-radius: 8px; padding: 5px 9px; font-size: 12.5px; color: var(--text-2); margin: 2px 0 6px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.bub .quote b { display: block; color: var(--primary-ink); font-size: 11.5px; }
.bub .tpl-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--violet); margin-bottom: 3px; }
.bub .tpl-tag .i { width: 13px; height: 13px; }
.media-img { display: block; margin: 2px -6px 4px; border-radius: 12px; overflow: hidden; background: var(--bg-sunken); cursor: zoom-in; }
.media-img img { display: block; max-width: 100%; max-height: 340px; min-width: 120px; object-fit: cover; }
.media-img.sticker { background: none; max-width: 150px; }
.bub video { display: block; max-width: 100%; max-height: 340px; border-radius: 12px; margin: 2px -6px 4px; background: #000; }
.bub audio { display: block; width: 280px; max-width: 100%; height: 40px; margin: 4px 0 2px; }
.bub .att { margin: 2px -4px 4px; min-width: 220px; }
.media-wait { display: flex; align-items: center; gap: 9px; padding: 10px 4px; font-size: 13px; color: var(--text-2); }
.loc { display: flex; gap: 10px; align-items: center; padding: 6px 2px; color: var(--text); }
.loc .row-icon { width: 38px; height: 38px; }
.bub .react { position: absolute; bottom: -13px; right: 12px; background: var(--raised); border: 1px solid var(--border-strong); border-radius: 999px; font-size: 13px; line-height: 1; padding: 3px 6px; box-shadow: var(--shadow-sm); }
.bub-row.in .bub .react { right: auto; left: 12px; }
.bub-tools { opacity: 0; transition: opacity .12s; display: flex; flex-direction: column; gap: 2px; align-self: center; }
.bub-row:hover .bub-tools { opacity: 1; }
.bub-tools .icon-btn { width: 30px; height: 30px; border-radius: 9px; color: var(--text-3); }
.bub-row.out .bub-tools, .bub-row.note .bub-tools { order: -1; }
.chat-new { position: sticky; bottom: 4px; display: flex; justify-content: center; pointer-events: none; z-index: 3; }
.chat-new button { pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border-radius: 999px; background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow); }

/* Compositor */
.chat-composer { flex: none; border-top: 1px solid var(--border); background: var(--surface); padding: 10px 14px 12px; position: relative; }
.chat-composer .inner { max-width: 880px; margin: 0 auto; }
.cc-bar { display: flex; align-items: center; gap: 10px; padding: 7px 10px 7px 12px; margin-bottom: 8px; border-radius: 12px; background: var(--bg-sunken); font-size: 12.5px; color: var(--text-2); }
.cc-bar .grow { flex: 1; min-width: 0; }
.cc-bar b { color: var(--text); font-weight: 600; }
.cc-bar .icon-btn { width: 28px; height: 28px; }
.cc-box { display: flex; align-items: flex-end; gap: 4px; border: 1px solid var(--border-strong); border-radius: 16px; padding: 4px; background: var(--bg-soft); transition: border-color .15s, box-shadow .15s, background .15s; }
.cc-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); background: var(--surface); }
.cc-box.note { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.cc-box.note:focus-within { box-shadow: 0 0 0 4px var(--warning-soft); border-color: var(--warning); }
.cc-box textarea { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; resize: none; padding: 8px 6px; max-height: 200px; line-height: 1.45; display: block; }
.cc-box textarea:disabled { cursor: not-allowed; }
.cc-box .icon-btn { width: 38px; height: 38px; border-radius: 12px; }
.send-btn { width: 38px; height: 38px; border-radius: 12px; background: var(--text); color: var(--bg); display: grid; place-items: center; flex: none; transition: opacity .15s, transform .08s; }
.send-btn:hover { opacity: .88; }
.send-btn:active { transform: translateY(1px); }
.send-btn:disabled { opacity: .3; cursor: not-allowed; }
.cc-box.note .send-btn { background: var(--warning); color: #fff; }
.cc-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12.5px; color: var(--text-3); }
.cc-foot .seg { margin-top: 0; }
.cc-foot .seg button { height: 26px; font-size: 12px; padding: 0 10px; }
.cc-foot .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-foot .grow.warn { color: var(--warning); font-weight: 550; }
.window-banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--warning-soft); font-size: 13px; margin-bottom: 8px; }
.window-banner .i { color: var(--warning); }
.window-banner .grow { flex: 1; min-width: 0; }
.qr-pop {
  position: absolute; left: 14px; right: 14px; bottom: calc(100% - 6px); max-width: 640px; max-height: 300px; overflow-y: auto; z-index: 20;
  background: var(--raised); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 6px; animation: pop .14s var(--ease);
}
.qr-pop button { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; padding: 8px 10px; border-radius: 10px; }
.qr-pop button.on, .qr-pop button:hover { background: var(--bg-sunken); }
.qr-pop .sc { font-family: var(--mono); font-size: 12px; color: var(--primary-ink); background: var(--primary-soft); padding: 2px 7px; border-radius: 6px; flex: none; margin-top: 1px; }
.qr-pop .tx { min-width: 0; font-size: 13px; }
.qr-pop .tx b { display: block; font-weight: 600; }
.qr-pop .tx span { color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.qr-pop .none { padding: 14px; text-align: center; color: var(--text-3); font-size: 13px; }

/* Plantillas */
.tpl-list { display: grid; gap: 8px; max-height: 300px; overflow-y: auto; margin-bottom: 14px; padding: 2px; }
.tpl-item { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 11px 13px; border-radius: 13px; border: 1px solid var(--border-strong); background: var(--surface); transition: border-color .15s, box-shadow .15s; width: 100%; }
.tpl-item:hover { border-color: var(--border-3); }
.tpl-item.on { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.tpl-item.off { opacity: .55; }
.tpl-item .grow { flex: 1; min-width: 0; }
.tpl-item .t { font-weight: 600; font-size: 13.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tpl-item .b { font-size: 12.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
.tpl-preview { background: var(--bg-sunken); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.tpl-preview .bub { max-width: 100%; margin-left: auto; background: color-mix(in srgb, var(--primary) 11%, var(--surface)); border-color: transparent; }
.tpl-preview .h { font-weight: 650; margin-bottom: 4px; }
.tpl-preview .f { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.tpl-preview .btns { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; border-top: 1px solid var(--border); padding-top: 6px; }
.tpl-preview .btns span { text-align: center; color: var(--primary); font-weight: 600; font-size: 13px; padding: 4px; }
.tpl-preview mark { background: var(--warning-soft); color: inherit; border-radius: 4px; padding: 0 3px; }

/* Números y equipo */
.space-card .card-head h3 { display: flex; align-items: center; gap: 9px; }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 14px; font-size: 13px; padding: 4px 0 14px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.copy-field { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border-radius: 12px; background: var(--bg-sunken); border: 1px solid var(--border); font-family: var(--mono); font-size: 12.5px; }
.copy-field span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row { display: grid; grid-template-columns: minmax(0, 1fr) 190px 150px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.member-row:last-child { border-bottom: 0; }
.member-row .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.member-row .input { height: 36px; }
.member-row.off .input, .member-row.off .check-row { opacity: .4; pointer-events: none; }
.space-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.space-chips .chip .dot { width: 7px; height: 7px; }
.qr-card .row { align-items: flex-start; }
.qr-card .sc { font-family: var(--mono); font-size: 12px; color: var(--primary-ink); background: var(--primary-soft); padding: 2px 8px; border-radius: 7px; flex: none; }
.qr-card .body-prev { color: var(--text-2); font-size: 13px; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Gráfica de barras del resumen */
.bars-svg { display: block; width: 100%; height: 210px; overflow: visible; }
.bars-svg .gl { stroke: var(--grid); }
.bars-svg .tick { fill: var(--text-3); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.bars-svg rect.in { fill: var(--chart-a); }
.bars-svg rect.out { fill: var(--chart-b); }
.bars-svg rect:hover { opacity: .8; }

@media (max-width: 860px) {
  .chat-head { padding: calc(6px + env(safe-area-inset-top)) 6px 6px; min-height: 58px; gap: 4px; }
  .chat-head .back-btn { display: inline-grid; }
  .chat-head .hide-mobile { display: none; }
  .assign-btn { max-width: 120px; height: 40px; }
  .assign-btn .lbl { display: none; }
  .assign-btn.none .lbl { display: inline; }
  .chat-scroll { padding: 10px 10px 12px; }
  .bub { max-width: 86%; }
  .bub-tools { display: none; }
  .chat-composer { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .cc-foot .hide-sm { display: none; }
  .member-row { grid-template-columns: 1fr 1fr; }
  .member-row .who { grid-column: 1 / -1; }
  .kv { grid-template-columns: 110px minmax(0, 1fr); }
  .msg .assignee { max-width: 110px; }
}
.count.faint-count { background: var(--bg-sunken); color: var(--text-3); }
.chat-head .who .s .sp-tag { display: inline-flex; align-items: center; gap: 5px; }
.list-head .seg button { padding: 0 9px; }
@media (max-width: 860px) { .chat-head .who .s .sp-tag { display: none; } }
