/* Panel de correo. Los colores de marca (--brand*) los inyecta /brand.css según el subdominio. */

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(/fonts/plus-jakarta-sans-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(/fonts/plus-jakarta-sans-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Valores por defecto; /brand.css los reemplaza por los de la marca */
  --brand: #BE0811;
  --brand-dark: #96060D;
  --brand-soft: #FBEAEB;

  --primary: var(--brand);
  --primary-dark: var(--brand-dark);
  --primary-soft: var(--brand-soft);
  --primary-ink: var(--brand-ink, var(--brand)); /* texto en color de marca */
  --logo-bg: #FFFFFF;

  --bg: #F4F4F5;
  --card: #FFFFFF;
  --line: #E4E4E7;
  --ink: #141414;
  --ink-2: #52525B;
  --ink-3: #5F5F68;
  --side: #141414;
  --side-ink: #D4D4D8;
  --side-muted: #A1A1AA;

  --live: #1F9D55;
  --live-bg: #E9F7EF;
  --live-ink: #135C33;

  --r-card: 20px;
  --r-ctl: 12px;
  --r-input: 14px;
  --r-pill: 16px;
  --shadow: 0 18px 48px rgba(20, 20, 20, .18), 0 2px 8px rgba(20, 20, 20, .08);

  --tabbar: 72px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  font-family: var(--font);
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 200; padding: 10px 14px; border-radius: var(--r-ctl); background: var(--ink); color: #fff; font-weight: 700; }
.skip-link:focus { top: 12px; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------- Botones ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--r-ctl);
  border: 1px solid transparent; background: var(--card); font-weight: 700; font-size: 14px;
  white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-outline { border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--ink-3); background: #FAFAFA; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg); }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: var(--r-ctl); background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.icon-btn.on-dark { color: var(--side-ink); }
.icon-btn.on-dark:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.icon-btn.icon-danger:hover { background: var(--primary-soft); color: var(--primary-ink); }
.link-btn { min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--primary-ink); font-weight: 700; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }
.spacer { flex: 1; }

/* ---------------- Logo de marca ---------------- */
.brand-logo {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center; overflow: hidden;
  border-radius: 12px; background: var(--logo-bg);
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-logo.fallback { background: var(--primary); color: #fff; font-weight: 800; font-size: 18px; }
.brand-logo-sm { width: 32px; height: 32px; border-radius: 10px; }
.brand-logo-sm.fallback { font-size: 15px; }
.brand-logo-lg { width: 48px; height: 48px; border-radius: 14px; }
.brand-logo-lg.fallback { background: #fff; color: var(--primary-ink); font-size: 22px; }

/* ---------------- Avatares ---------------- */
.avatar {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: #E4E4E7; color: #3F3F46; font-weight: 700; font-size: 14px; letter-spacing: .02em; user-select: none;
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.avatar-primary { background: var(--primary); color: #fff; }
/* Foto de perfil encima de las iniciales (si no carga, se ven las iniciales) */
.avatar { position: relative; overflow: hidden; }
.avatar > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; background: #fff; }
.avatar-xl { width: 64px; height: 64px; font-size: 20px; }

/* =========================================================
   LOGIN
   ========================================================= */
.login-page { min-height: 100%; background: #FAFAFA; }
.login-split { min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; }

.login-hero {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
  gap: 32px; padding: 48px; background: var(--primary); color: #fff;
}
.hero-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; font-size: 18px; }
.hero-brand strong { font-weight: 800; letter-spacing: .03em; }
/* Login neutral (CREDIMAS + MotoPlus): panel oscuro con los dos logos */
.login-hero-neutral { background: #141414; }
.hero-logos { position: relative; z-index: 1; display: flex; align-items: center; gap: 20px; }
.hero-logos img { width: 56px; height: 56px; border-radius: 14px; display: block; box-shadow: 0 0 0 1px rgba(255, 255, 255, .2); }
#email::placeholder { font-size: 14px; }
.hero-divider { width: 1px; height: 56px; background: rgba(255, 255, 255, .2); }
.hero-copy { position: relative; z-index: 1; max-width: 520px; }
.hero-title { margin: 0 0 18px; font-size: 52px; line-height: 1.05; font-weight: 800; letter-spacing: -.02em; }
.hero-text { margin: 0; font-size: 18px; line-height: 1.55; font-weight: 500; }
.hero-host { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 600; font-size: 15px; }
.hero-host .dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.hero-rings { position: absolute; right: -150px; bottom: -150px; width: 460px; height: 460px; pointer-events: none; }

.login-main { display: grid; place-items: center; padding: 48px 24px; }
.login-box { width: 100%; max-width: 400px; }
.login-box h1 { margin: 0 0 8px; font-size: 32px; font-weight: 800; letter-spacing: -.01em; }
.login-sub { margin: 0 0 28px; color: var(--ink-2); font-size: 15px; }
.login-form { display: grid; gap: 8px; }
.login-form > label { font-weight: 700; font-size: 14px; margin-top: 10px; }
.input {
  width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--r-input);
  background: #fff; font-size: 16px;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input::placeholder { color: var(--ink-3); }
.pass-wrap { position: relative; }
.pass-wrap .input { padding-right: 96px; }
.pass-toggle {
  position: absolute; right: 2px; top: 2px; min-width: 44px; height: 44px; padding: 0 14px;
  border: 0; border-radius: 12px; background: transparent; color: var(--primary-ink); font-weight: 700; font-size: 14px;
}
.pass-toggle:hover { background: var(--primary-soft); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 4px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }
.form-msg { margin-top: 6px; padding: 12px 14px; border-radius: var(--r-ctl); font-size: 14px; font-weight: 600; }
.form-msg.error { background: var(--primary-soft); color: var(--primary-ink); }
.form-msg.info { background: var(--bg); color: var(--ink-2); }
.btn-lg { min-height: 52px; margin-top: 12px; font-size: 16px; border-radius: 14px; }
.secure-note { display: flex; align-items: flex-start; gap: 8px; margin: 14px 0 0; color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.secure-note .ic { width: 16px; height: 16px; margin-top: 1px; }

/* =========================================================
   APP
   ========================================================= */
body.app { height: 100dvh; overflow: hidden; }
.shell { display: flex; height: 100%; }

/* ---------- Barra lateral ---------- */
.sidebar {
  width: 248px; flex: none; display: flex; flex-direction: column; gap: 20px;
  padding: 24px 16px; background: var(--side); color: var(--side-ink); overflow-y: auto;
}
.sb-head { display: flex; align-items: center; gap: 12px; }
.sb-brand { flex: 1; min-width: 0; display: grid; }
.sb-brand strong { color: #fff; font-weight: 800; font-size: 16px; letter-spacing: .03em; overflow: hidden; text-overflow: ellipsis; }
.sb-brand span { color: var(--side-muted); font-size: 13px; }
.compose-btn { width: 100%; min-height: 48px; font-size: 15px; }
.folders { display: grid; gap: 2px; }
.folder {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: var(--r-ctl); background: transparent; color: var(--side-ink);
  text-align: left; font-size: 14px; font-weight: 500;
}
.folder:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.folder.active { background: rgba(255, 255, 255, .09); color: #fff; font-weight: 600; }
.folder .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count-pill {
  min-width: 24px; height: 22px; padding: 0 8px; border-radius: var(--r-pill);
  display: inline-grid; place-items: center; background: var(--primary); color: #fff; font-size: 12px; font-weight: 700;
}
.account-card {
  margin-top: auto; display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 10px;
  padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, .06);
}
.acc-actions { grid-column: 1 / -1; display: flex; gap: 6px; }
.acc-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 8px;
  border: 0; border-radius: var(--r-ctl); background: rgba(255, 255, 255, .06); color: var(--side-ink); font-size: 13px; font-weight: 600;
}
.acc-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.acc-btn .ic { width: 17px; height: 17px; }
.acc-btn.acc-icon { flex: 0 0 44px; padding: 0; }
.acc-text { flex: 1; min-width: 0; display: grid; }
.acc-text strong { color: #fff; font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-text span { color: var(--side-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scrim { display: none; }

/* ---------- Columna principal ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; padding: 20px 24px 24px; }
.mobile-header { display: none; }
.main-top { display: flex; align-items: center; gap: 16px; }
.search { position: relative; flex: 1; max-width: 680px; }
.search input {
  width: 100%; height: 48px; padding: 0 16px 0 46px; border: 1px solid var(--line); border-radius: var(--r-input);
  background: var(--card); font-size: 15px;
}
.search input::placeholder { color: var(--ink-3); }
.search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-ic { position: absolute; left: 15px; top: 14px; color: var(--ink-3); pointer-events: none; display: flex; }
/* Buscando: la lupa se cambia por un spinner pequeño */
.search-spinner {
  position: absolute; left: 17px; top: 16px; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--primary); display: none; pointer-events: none;
  animation: spin .7s linear infinite;
}
.search.searching .search-spinner { display: block; }
.search.searching .search-ic { visibility: hidden; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .search-spinner { animation-duration: 2s; } }
/* Panel de atajos debajo del buscador */
.search-help {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px); padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.search-help-title { margin: 0 0 8px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.search-help-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--bg); color: var(--ink); font: 600 13px ui-monospace, "Cascadia Code", Consolas, monospace;
}
.chip:hover { border-color: var(--primary); color: var(--primary-ink); }
.search-help-example { margin: 10px 0 0; font-size: 12px; color: var(--ink-2); line-height: 1.6; }
.search-help-example .link-btn { min-height: 28px; padding: 0 2px; font: 700 12px ui-monospace, "Cascadia Code", Consolas, monospace; }

.live-pill {
  display: inline-flex; align-items: center; gap: 8px; flex: none; height: 32px; padding: 0 12px;
  border-radius: var(--r-pill); background: #E4E4E7; color: var(--ink-2); font-size: 13px; font-weight: 700;
}
.desktop-only { margin-left: auto; }
.mobile-only { display: none; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #71717A; }
.live-pill.live { background: var(--live-bg); color: var(--live-ink); }
.live-pill.live .live-dot { background: var(--live); animation: pulse 1.8s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(31, 157, 85, .55); }
  70% { box-shadow: 0 0 0 7px rgba(31, 157, 85, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 157, 85, 0); }
}
@media (prefers-reduced-motion: reduce) { .live-pill.live .live-dot { animation: none; } }

.banner {
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-radius: var(--r-input);
  background: var(--primary-soft); color: var(--primary-ink); font-size: 14px; font-weight: 600;
}
.banner-text { flex: 1; }
.banner .icon-btn { color: var(--primary-ink); }

.columns { flex: 1; min-height: 0; display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 16px; }
.list-card, .reader-card {
  min-height: 0; display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
}

/* ---------- Lista ---------- */
.list-head { display: flex; align-items: baseline; gap: 12px; padding: 20px 20px 12px; }
.folder-title { flex: 1; min-width: 0; margin: 0; font-size: 20px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-title .t-short { display: none; }
.unread-label { flex: none; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.filters { display: flex; align-items: center; gap: 8px; padding: 0 12px 12px 20px; border-bottom: 1px solid var(--line); }
.pills { flex: 1; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.pill {
  flex: none; min-height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--card); color: var(--ink-2); font-size: 13px; font-weight: 700;
}
.pill:hover { border-color: var(--ink-3); color: var(--ink); }
.pill.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.search-info { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0 8px; padding: 4px 12px 4px 20px; background: var(--bg); color: var(--ink-2); font-size: 13px; }
.search-info .link-btn { min-height: 36px; }

.message-list { flex: 1; min-height: 0; overflow-y: auto; margin: 0; padding: 8px; list-style: none; overscroll-behavior: contain; }
.message-list:focus { outline: none; }
.msg {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; width: 100%; padding: 12px;
  border: 0; border-radius: 14px; background: transparent; text-align: left; color: var(--ink);
}
.msg:hover { background: #FAFAFA; }
.msg.active { background: var(--primary-soft); }
.msg:focus-visible { outline-offset: -2px; }
.msg-body { min-width: 0; display: grid; gap: 3px; }
.msg-top { display: flex; align-items: baseline; gap: 8px; }
.msg-from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.msg-date { flex: none; font-size: 12px; color: var(--ink-3); font-weight: 500; }
/* Carpeta del resultado al buscar en todas las carpetas */
.folder-tag { flex: none; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 1px 8px; border-radius: var(--r-pill); background: var(--bg); color: var(--ink-2); font-size: 11px; font-weight: 700; }
.msg-subject { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 14px; font-weight: 500; }
.msg-subject-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-subject .ic { width: 15px; height: 15px; color: var(--ink-3); }
.unread-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--primary); }
.msg-preview { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.unread .msg-from, .msg.unread .msg-subject-text { font-weight: 700; }
.msg.unread .msg-date { color: var(--primary-ink); font-weight: 700; }
.msg.fresh { animation: fresh 2.4s ease-out; }
@keyframes fresh { from { background: var(--primary-soft); } }

.list-foot { display: flex; align-items: center; justify-content: flex-end; gap: 2px; padding: 4px 8px; border-top: 1px solid var(--line); }
.page-info { margin-right: auto; padding-left: 12px; font-size: 12px; color: var(--ink-2); font-weight: 600; }

.empty { display: grid; place-items: center; align-content: center; gap: 8px; padding: 40px 20px; color: var(--ink-2); text-align: center; font-size: 14px; }
.empty p { margin: 0; }
.empty .ic { width: 44px; height: 44px; stroke-width: 1.4; color: var(--ink-3); }
.reader-empty { flex: 1; }

/* ---------- Lectura ---------- */
.reader { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.reader-toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.reader-head { padding: 20px 24px 12px; }
.r-subject { margin: 0 0 18px; font-size: 26px; line-height: 1.25; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
.r-from { display: flex; align-items: flex-start; gap: 12px; }
.r-from-text { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
.r-from-line strong { font-weight: 700; }
.r-addr { color: var(--ink-2); }
.r-to { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.r-date { flex: none; color: var(--ink-2); font-size: 13px; font-weight: 500; white-space: nowrap; }
.images-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 0 24px 8px; padding: 8px 8px 8px 14px;
  border-radius: var(--r-ctl); background: var(--bg); color: var(--ink-2); font-size: 13px;
}
.images-text { flex: 1; min-width: 180px; }
.r-body { flex: 1; min-height: 200px; width: 100%; border: 0; background: #fff; }

.att-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 12px 24px; list-style: none; border-top: 1px solid var(--line); max-height: 180px; overflow-y: auto; }
.att-grid:empty { display: none; }
.att-card {
  display: flex; align-items: center; gap: 12px; width: 240px; max-width: 100%; min-height: 56px; padding: 8px 12px 8px 8px;
  border: 1px solid var(--line); border-radius: 14px; color: var(--ink); text-decoration: none;
}
.att-card:hover { border-color: var(--primary); }
.att-ext {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary-ink); font-size: 11px; font-weight: 800; letter-spacing: .03em;
}
.att-text { min-width: 0; display: grid; }
.att-name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-meta { font-size: 12px; color: var(--ink-2); }
.att-meta b { color: var(--primary-ink); font-weight: 700; }

.quick-reply {
  display: flex; align-items: flex-end; gap: 8px; margin: 0 16px 16px; padding: 8px 8px 8px 16px;
  border-radius: 16px; background: var(--bg);
}
.quick-reply textarea {
  flex: 1; min-height: 44px; max-height: 160px; padding: 11px 0; border: 0; background: transparent;
  resize: none; font-size: 15px; line-height: 1.45;
}
.quick-reply textarea:focus { outline: none; }
.quick-reply:focus-within { box-shadow: 0 0 0 2px var(--primary-soft); }

/* ---------- Redactar (ventana flotante) ---------- */
.compose-window {
  position: fixed; z-index: 80; right: 24px; bottom: 24px; width: 480px;
  height: min(620px, calc(100dvh - 48px));
}
.compose, .modal-card {
  height: 100%; display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow);
}
.compose-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 20px; background: var(--side); color: #fff; }
.compose-head h2 { flex: 1; margin: 0; font-size: 15px; font-weight: 700; }
.field { flex: none; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 12px 0 20px; border-bottom: 1px solid var(--line); }
.field label, .field-label { flex: none; width: 52px; color: var(--ink-2); font-size: 14px; font-weight: 500; }
.field input { flex: 1; min-width: 0; height: 46px; border: 0; background: transparent; font-size: 15px; }
.field input:focus { outline: none; }
.field:focus-within { border-bottom-color: var(--primary); }
.field-static { flex: 1; min-width: 0; font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-body { flex: 1; min-height: 120px; width: 100%; padding: 16px 20px; border: 0; resize: none; font-size: 15px; line-height: 1.6; }
.compose-body:focus { outline: none; }
.compose-files {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px;
  margin: 0; padding: 0 20px 10px; list-style: none; max-height: 136px; overflow-y: auto;
}
.compose-files:empty { display: none; }
.file-chip {
  display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 48px; padding: 4px 2px 4px 6px;
  border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--card); font-size: 13px;
}
.chip-text { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.file-chip .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-chip .icon-btn { width: 40px; height: 40px; }
.file-chip .icon-btn .ic { width: 16px; height: 16px; }
.file-ic { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 8px; }
.file-ic .ic { width: 18px; height: 18px; }
.ft-pdf { background: #FBEAEB; color: #8E0710; }
.ft-image { background: #F1EAFB; color: #5B2A9E; }
.ft-excel { background: #EAF5EE; color: #135C33; }
.ft-word { background: #E8EEF9; color: #1E3A8A; }
.ft-other { background: #E4E4E7; color: #3F3F46; }

/* Arrastrar y soltar */
.compose-window .compose { position: relative; }
.drop-zone {
  position: absolute; inset: 56px 12px 12px; z-index: 2; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border: 2px dashed var(--primary); border-radius: 16px; background: color-mix(in srgb, var(--primary-soft) 92%, transparent);
  color: var(--primary-ink); font-weight: 700; font-size: 15px; pointer-events: none;
}
.drop-zone .ic { width: 28px; height: 28px; }
.compose-window.drop-active .drop-zone { display: flex; }

/* Miniaturas de imágenes adjuntas */
.att-thumb { flex-direction: column; align-items: stretch; gap: 8px; width: 168px; padding: 6px; background: var(--card); text-align: left; font: inherit; cursor: zoom-in; }
.att-thumb img { width: 100%; height: 104px; object-fit: cover; border-radius: 10px; background: var(--bg); display: block; }
.att-thumb .att-text { padding: 0 4px 2px; }

/* Visor de imágenes */
.lightbox { position: fixed; inset: 0; z-index: 120; display: flex; flex-direction: column; background: rgba(10, 10, 10, .92); }
.lb-bar { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 20px; padding-top: max(8px, env(safe-area-inset-top)); color: #fff; }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.lb-btn { background: rgba(255, 255, 255, .12); color: #fff; text-decoration: none; }
.lb-btn:hover { background: rgba(255, 255, 255, .2); }
.lb-btn .ic { width: 16px; height: 16px; }
.lb-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px 16px 24px; cursor: zoom-out; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; background: #fff; cursor: default; }
.compose-foot { flex: none; display: flex; align-items: center; gap: 6px; padding: 10px 12px 10px 16px; border-top: 1px solid var(--line); }
.c-size { font-size: 12px; color: var(--ink-2); }
.c-size.over { color: var(--primary-ink); font-weight: 700; }
/* Firma bajo el mensaje (vista previa no editable) */
.compose-sig { flex: none; margin: 0 20px 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.compose-sig-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.compose-sig-label { color: var(--ink-2); font-size: 12px; font-weight: 600; }
.compose-sig-toggle { min-height: 32px; padding: 0 4px; font-size: 12px; }
.compose-sig-preview { display: block; width: 100%; height: 130px; max-height: 180px; border: 0; background: #fff; pointer-events: none; }

/* Ajustes (diálogo centrado) */
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px; background: rgba(20, 20, 20, .45); }
.modal-card { width: 100%; max-width: 520px; height: auto; max-height: calc(100dvh - 48px); }
.settings-body { flex: 1; overflow-y: auto; display: grid; align-content: start; gap: 6px; padding: 20px; }
.settings-body label { font-weight: 700; font-size: 14px; margin-top: 8px; }
.settings-body input, .settings-body textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-ctl); font-size: 15px;
}
.settings-body textarea { resize: vertical; line-height: 1.5; }
.settings-body input:focus, .settings-body textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.hint { margin: 0; color: var(--ink-2); font-size: 13px; }

/* Ajustes: secciones (nombre y firma, verificación en dos pasos, sesiones) */
.settings-card { max-width: 600px; }
.settings-card .settings-body { gap: 20px; }
.settings-section { display: grid; gap: 6px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.settings-section:last-child { padding-bottom: 4px; border-bottom: 0; }
.settings-section h3 { margin: 0; font-size: 16px; font-weight: 800; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.state-pill { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: var(--r-pill); background: #E4E4E7; color: var(--ink-2); font-size: 12px; font-weight: 700; }
.state-pill.on { background: var(--live-bg); color: var(--live-ink); }
.btn-danger { color: var(--primary-ink); }
.btn-danger:hover { background: var(--primary-soft); border-color: var(--primary); }
.steps { margin: 4px 0 0; padding-left: 20px; color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.tfa-qr { width: 200px; height: 200px; margin: 8px 0; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.tfa-secret { padding: 2px 6px; border-radius: 6px; background: var(--bg); color: var(--ink); font: 600 13px ui-monospace, "Cascadia Code", Consolas, monospace; word-break: break-all; }
.notice { margin: 0; padding: 12px 14px; border-radius: 12px; background: #FFF3E0; color: #7A4100; font-size: 14px; line-height: 1.5; }
.code-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 8px 0 0; padding: 0; list-style: none; }
.code-list code { display: block; padding: 10px; border: 1px dashed #A1A1AA; border-radius: 10px; text-align: center; font: 600 15px ui-monospace, "Cascadia Code", Consolas, monospace; letter-spacing: .05em; }
.sess-list { display: grid; gap: 8px; margin: 4px 0 0; padding: 0; list-style: none; }
.sess { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; }
.sess.current { background: #FAFAFA; }
.sess-ic { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--bg); color: var(--ink-2); }
.sess-text { flex: 1; min-width: 0; display: grid; }
.sess-text strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess-text .hint { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Interruptor (Ajustes → Notificaciones) */
.switch-row { display: flex; align-items: center; gap: 16px; min-height: 44px; cursor: pointer; }
.switch-text { flex: 1; min-width: 0; display: grid; gap: 2px; font-size: 14px; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 44px; height: 26px; margin: 0;
  border-radius: 13px; background: #A1A1AA; cursor: pointer; transition: background-color .15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Ajustes: foto y firma */
.photo-row { display: flex; align-items: center; gap: 16px; }
.photo-actions { flex: 1; min-width: 0; }
.photo-actions .section-actions { margin-top: 6px; }
.sub-head { margin: 14px 0 0; font-size: 14px; font-weight: 800; }
.sig-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; }
.sig-field { display: grid; gap: 6px; }
.optional { color: var(--ink-2); font-weight: 500; }
.field-caption { margin: 10px 0 0; font-weight: 700; font-size: 14px; }
.sig-preview { width: 100%; height: 170px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.advanced { margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; }
.advanced[open] { padding-bottom: 12px; }
.advanced summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 700; font-size: 14px; color: var(--ink-2); }
.advanced[open] summary { color: var(--ink); }
@media (max-width: 600px) { .sig-grid { grid-template-columns: 1fr; } }

/* Login: código de verificación */
.code-input { font-size: 20px; letter-spacing: .18em; text-align: center; }
.link-start { justify-self: start; padding-left: 0; }

/* Autocompletado */
.ac-list {
  position: fixed; z-index: 95; margin: 0; padding: 6px; list-style: none; max-height: 300px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
}
.ac-item { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 10px; border-radius: 10px; cursor: pointer; }
.ac-item.active, .ac-item:hover { background: var(--primary-soft); }
.ac-text { min-width: 0; display: grid; }
.ac-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-addr { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Toast de correo nuevo */
.mail-toasts { position: fixed; z-index: 110; top: 20px; right: 24px; display: grid; gap: 10px; width: 340px; }
.mail-toast {
  display: flex; align-items: flex-start; border-radius: 16px; background: var(--side); color: #fff;
  box-shadow: var(--shadow); animation: slide-in .22s ease-out;
}
.mail-toast-main { flex: 1; min-width: 0; display: flex; gap: 12px; padding: 14px 0 14px 14px; border: 0; background: none; color: inherit; text-align: left; border-radius: 16px; }
.mail-toast-main:focus-visible { outline-color: #fff; }
.mt-text { min-width: 0; display: grid; gap: 2px; }
.mt-title { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-subject { font-size: 13px; color: var(--side-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-time { font-size: 12px; color: var(--side-muted); }
.mt-muted { display: inline-flex; vertical-align: -3px; margin-left: 6px; color: var(--side-muted); }
.mt-muted .ic { width: 15px; height: 15px; }
.mail-toast .icon-btn { color: var(--side-ink); margin: 4px 4px 0 0; }
.mail-toast .icon-btn:hover { background: rgba(255, 255, 255, .09); color: #fff; }
@keyframes slide-in { from { opacity: 0; transform: translateX(16px); } }

/* Avisos generales */
.toasts { position: fixed; z-index: 105; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 14px; background: var(--side); color: #fff; box-shadow: var(--shadow); font-size: 14px; font-weight: 600; pointer-events: auto; animation: toast-in .2s ease-out; }
.toast.error { background: var(--primary); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Elementos solo móviles */
.fab, .tabbar, .only-mobile { display: none; }

/* =========================================================
   Tablet (768–1099): la lectura se abre encima de la lista
   ========================================================= */
@media (max-width: 1099px) {
  .columns { grid-template-columns: minmax(0, 1fr); }
  .reader-card {
    position: fixed; z-index: 60; inset: 0; border: 0; border-radius: 0;
    transform: translateX(105%); transition: transform .22s ease; visibility: hidden;
  }
  body.reading .reader-card { transform: none; visibility: visible; }
  .reader-toolbar { padding-top: max(12px, env(safe-area-inset-top)); }
}
@media (min-width: 1100px) {
  .only-narrow { display: none !important; }
}

/* =========================================================
   Móvil (< 768)
   ========================================================= */
@media (max-width: 767px) {
  body.app { background: var(--card); }
  .only-mobile { display: inline-grid; }
  .desktop-only { display: none; }
  .mobile-only { display: inline-flex; }

  /* Barra lateral como cajón ("Cuenta") */
  .sidebar {
    position: fixed; z-index: 70; top: 0; bottom: 0; left: 0; width: min(320px, 88vw);
    padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom));
    transform: translateX(-105%); transition: transform .22s ease; visibility: hidden;
  }
  body.menu-open .sidebar { transform: none; visibility: visible; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(20, 20, 20, .45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.menu-open .scrim { opacity: 1; pointer-events: auto; }

  .main { padding: 0; gap: 0; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  .mobile-header {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px 6px 16px;
    padding-top: max(10px, env(safe-area-inset-top));
  }
  .mh-brand { flex: 1; font-weight: 800; letter-spacing: .03em; font-size: 16px; }
  .avatar-btn { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; }
  .main-top { padding: 6px 16px 4px; }
  .search { max-width: none; }
  .search input { height: 46px; border-color: transparent; background: var(--bg); }
  .search-ic { top: 13px; }
  .banner { margin: 8px 16px 0; }

  .columns { gap: 0; }
  .list-card { border: 0; border-radius: 0; }
  .list-head { align-items: center; padding: 14px 16px 10px; }
  .folder-title { font-size: 24px; }
  .folder-title .t-full { display: none; }
  .folder-title .t-short { display: inline; }
  .unread-label { display: none; }
  .filters { padding: 0 8px 10px 16px; }
  .message-list { padding: 4px 8px 96px; }

  .reader-head { padding: 16px 16px 10px; }
  .r-subject { font-size: 22px; }
  .reader-toolbar { gap: 4px; padding-left: 8px; padding-right: 8px; }
  .reader-toolbar .btn-outline { padding: 0 12px; }
  .list-foot { justify-content: flex-start; }
  .page-info { margin-right: 4px; }
  .images-bar { margin: 0 16px 8px; }
  .att-grid { padding: 10px 16px; }
  .att-grid > li { flex: 1 1 100%; }
  .att-card { width: 100%; }
  .att-thumb .att-text { padding-bottom: 4px; }
  .att-thumb img { height: 140px; }
  .quick-reply { margin: 0 12px; margin-bottom: max(12px, env(safe-area-inset-bottom)); }

  .fab {
    position: fixed; z-index: 50; right: 16px; bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom));
    display: inline-flex; align-items: center; gap: 8px; height: 54px; padding: 0 22px;
    border: 0; border-radius: 27px; background: var(--primary); color: #fff; font-size: 15px; font-weight: 700;
    box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 35%, transparent), 0 2px 6px rgba(20, 20, 20, .15);
  }
  body.reading .fab, body.menu-open .fab, body.composing .fab { display: none; }

  .tabbar {
    position: fixed; z-index: 55; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
    height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--card); border-top: 1px solid var(--line);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    border: 0; background: none; color: var(--ink-2); font-size: 11px; font-weight: 600;
  }
  .tab .ic { width: 22px; height: 22px; }
  .tab.active { color: var(--primary-ink); font-weight: 700; }

  .compose-window { inset: 0; width: auto; height: auto; }
  .compose { border-radius: 0; }
  .compose-head { padding-top: max(6px, env(safe-area-inset-top)); }
  .compose-foot { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .modal { padding: 0; }
  .modal-card { max-width: none; height: 100%; max-height: none; border-radius: 0; }

  .mail-toasts { top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; width: auto; }
  .toasts { bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); }

  /* Login: panel de color arriba, más bajo */
  .login-split { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-hero { min-height: 240px; padding: 28px 24px; padding-top: max(28px, env(safe-area-inset-top)); gap: 20px; justify-content: flex-start; }
  .hero-title { font-size: 34px; margin: 0; }
  .hero-text, .hero-host { display: none; }
  .hero-rings { width: 300px; height: 300px; right: -110px; bottom: -110px; }
  .login-main { place-items: start center; padding: 28px 20px 32px; }
  .login-box h1 { font-size: 28px; }
  .login-sub { margin-bottom: 18px; }
}

@media (max-width: 479px) {
  .reader-toolbar .btn-outline { width: 44px; padding: 0; }
  .reader-toolbar .btn-label {
    position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
}
