:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #d9dee3;
  --text: #1f2933;
  --muted: #6b7280;
  --primary: #0d6efd;
  --primary-dark: #0b5ed7;
  --peligro: #dc3545;
  --naranja: #fd7e14;
  --naranja-osc: #e8590c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  height: 46px; padding: 0 1.2rem; background: #1f2933; color: #fff; overflow: hidden;
}
.topbar .brand { color: #fff; font-weight: 700; display: flex; align-items: center; gap: 0.45rem; }
.topbar .brand img { display: block; border-radius: 4px; }
.topbar .brand:hover { text-decoration: none; opacity: 0.85; }
.topbar nav { display: flex; gap: 1rem; flex: 1; }
.topbar nav a { color: #cbd5e1; }
.topbar nav a:hover { color: #fff; }
.userbox { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.userlink { color: #cbd5e1; }
.userlink:hover { color: #fff; }

/* Layout */
main { max-width: 1080px; margin: 1.5rem auto; padding: 0 1rem; }
main.full {
  max-width: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; height: calc(100dvh - 46px);
}
main.full > .flash { margin: 0.5rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem; }
h1 { font-size: 1.5rem; margin: 0; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 1.1rem; margin-bottom: 1.2rem; }
.muted { color: var(--muted); }

/* Botones */
button, .btn {
  background: var(--primary); color: #fff; border: 0; border-radius: 6px;
  padding: 0.5rem 0.9rem; font-size: 0.9rem; cursor: pointer;
}
button:hover, .btn:hover { background: var(--primary-dark); text-decoration: none; }
button.ghost, .btn.ghost { background: #eef2f7; color: var(--text); border: 1px solid var(--border); }
button.ghost:hover, .btn.ghost:hover { background: #e2e8f0; }
button.peligro { background: var(--peligro); }
button.peligro:hover { background: #b02a37; }
/* Eliminar un correo lo manda a la papelera: es reversible, va en naranja. */
button.eliminar { background: var(--naranja); color: #fff; }
button.eliminar:hover { background: var(--naranja-osc); }
.linkbtn { background: none; border: 0; color: var(--primary); cursor: pointer; padding: 0.35rem 0.5rem; font-size: 0.9rem; }
.linkbtn:hover { text-decoration: underline; }

/* Forms */
label { display: block; margin-bottom: 0.8rem; font-size: 0.9rem; font-weight: 600; }
input[type=text], input[type=password], input[type=email], input[type=number],
select, textarea {
  width: 100%; margin-top: 0.25rem; padding: 0.5rem;
  border: 1px solid var(--border); border-radius: 6px; font: inherit; font-weight: 400;
}
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .actions { display: flex; align-items: center; gap: 1rem; }
fieldset { grid-column: 1 / -1; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 0.8rem; }
legend { font-weight: 600; font-size: 0.85rem; }
.fila-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.min-sync { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
.min-sync input { width: 5rem; margin: 0; }
.fila-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 0 1rem; align-items: end; }
.checkbox { font-weight: 400; display: flex; align-items: center; gap: 0.5rem; }
.checkbox input { width: auto; margin: 0; }
.filtro-fila { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.filtro-fila input[type="text"] { flex: 1; min-width: 12rem; margin: 0; }
.filtro-fila select { margin: 0; width: auto; }
.stats-fila { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat-box { flex: 1; min-width: 10rem; }
.stat-box .stat-num { font-size: 1.4rem; font-weight: 700; }
.stat-box .stat-lbl { font-size: 0.8rem; color: var(--muted, #718096); }

.login-wrap { max-width: 360px; margin: 3rem auto; }
.login-wrap button { width: 100%; margin-top: 0.5rem; }
.login-pie { text-align: center; font-size: 0.88rem; margin-top: 1rem; }
.login-brand {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  margin-bottom: 1.5rem; font-size: 1.4rem; font-weight: 700; color: var(--text, #1a202c);
}
.login-brand img { display: block; border-radius: 6px; }
.login-brand:hover { text-decoration: none; opacity: 0.85; }

/* Flash */
.flash { padding: 0.7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.flash-success { background: #d1e7dd; color: #0f5132; }
.flash-danger  { background: #f8d7da; color: #842029; }
.flash-info    { background: #cfe2ff; color: #084298; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); }
th { background: #f0f3f6; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }

.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; color: #fff; background: #6c757d; }
.badge.ok { background: #198754; }
.badge.gris { background: #6c757d; }
.badge.aviso { background: #fd7e14; }

/* Cuentas */
.cuenta-card .cuenta-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.cuenta-acc { display: flex; align-items: center; gap: 0.6rem; }
.cuenta-acc form { display: inline; }
.cuenta-meta { margin-top: 0.5rem; font-size: 0.85rem; }
.cuenta-error { margin-top: 0.5rem; color: #842029; background: #f8d7da; padding: 0.5rem 0.7rem; border-radius: 6px; font-size: 0.85rem; }
.acciones-cuenta { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.acciones-cuenta form { display: inline; }

/* ================= Cliente de correo — 3 paneles ================= */
.mail-app {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 240px minmax(300px, 380px) 1fr;
}
.mail-app > * { min-height: 0; overflow-y: auto; }

/* Panel que responde a las flechas ↑ ↓ del teclado */
.panel-foco { box-shadow: inset 3px 0 0 var(--primary); }

button.mini {
  background: #eef2f7; color: var(--text); border: 1px solid var(--border);
  border-radius: 5px; padding: 0.2rem 0.5rem; font-size: 0.78rem;
}
button.mini:hover { background: #e2e8f0; }

/* Panel 1 — carpetas */
.panel-carpetas { background: #fbfcfd; border-right: 1px solid var(--border); padding: 0.6rem 0.5rem; font-size: 0.9rem; }
.acc-globales { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.acc-globales form { display: block; }
.redactar-btn { display: block; text-align: center; font-weight: 600; }
button.ancho { width: 100%; }
.cuenta-bloque { margin-bottom: 1rem; border-radius: 6px; }
.cuenta-bloque.arrastrando { opacity: 0.45; }
.cuenta-nombre {
  display: flex; align-items: center; gap: 0.35rem;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); padding: 0.2rem 0.35rem;
}
.cuenta-nombre form { display: inline; margin-left: auto; }
.cuenta-tit { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agarre { cursor: grab; color: #b6bfc9; font-size: 0.9rem; letter-spacing: -2px; flex: none; }
.agarre:active { cursor: grabbing; }
.cuenta-bloque:hover .agarre { color: var(--muted); }

/* Editor de firma: texto enriquecido con imagen (pegar/arrastrar) */
.firma-editor {
  margin-top: 0.25rem; min-height: 4.5rem; max-height: 18rem; overflow-y: auto;
  padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: 6px;
  font: inherit; background: #fff; line-height: 1.4;
}
.firma-editor:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.firma-editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.firma-editor.sobre-arrastre { outline: 2px dashed var(--primary); outline-offset: -2px; }
.firma-editor img { max-width: 100%; vertical-align: middle; }
#firma-estado:empty { display: none; }

/* Contraer / desplegar subcarpetas */
.fila-carpeta { display: flex; align-items: center; gap: 0.1rem; }
.fila-carpeta .carpeta { flex: 1; min-width: 0; }
.triangulo {
  flex: none; width: 16px; height: 20px; padding: 0; border: 0; background: none;
  color: var(--muted); font-size: 0.7rem; line-height: 20px; cursor: pointer;
  transition: transform 0.15s;
}
.triangulo:hover { background: none; color: var(--text); }
.triangulo.cerrado { transform: rotate(-90deg); }
.triangulo.hueco { cursor: default; }
.subcarpetas.oculto { display: none; }
.mini-nota { padding: 0.2rem 0.4rem; font-size: 0.8rem; }
ul.arbol { list-style: none; margin: 0; padding-left: 0; }
ul.arbol ul.arbol { padding-left: 0.85rem; }
.carpeta {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.32rem 0.4rem; border-radius: 5px; color: var(--text);
}
a.carpeta:hover { background: #eef2f7; text-decoration: none; }
a.carpeta.activa { background: var(--primary); color: #fff; }
.carpeta.noselect { color: var(--muted); }
.carpeta .nom { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.carpeta .cont { font-size: 0.7rem; background: #d0d7de; color: #1f2933; border-radius: 999px; padding: 0 0.4rem; }
a.carpeta.activa .cont { background: rgba(255, 255, 255, 0.3); color: #fff; }
.nueva-carpeta { margin-top: 0.3rem; font-size: 0.82rem; }
.nueva-carpeta summary { cursor: pointer; color: var(--primary); padding: 0.3rem 0.4rem; }
.nueva-carpeta form { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.4rem; }
.nueva-carpeta select, .nueva-carpeta input { margin: 0; font-size: 0.85rem; }

/* Panel 2 — lista de correos */
.panel-lista { border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.lista-cab, .lista-filtros { padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); background: #f7fafc; }
.lista-cab { display: flex; justify-content: space-between; align-items: center; }
.lista-cab form { display: inline; }
.lista-filtros { display: flex; gap: 0.4rem; }
.lista-filtros input[type=search] { flex: 1; margin: 0; }
.lista-filtros select { width: auto; margin: 0; }
.lista-orden {
  display: flex; align-items: center; gap: 0.4rem; flex: none;
  padding: 0.4rem 0.7rem; border-bottom: 1px solid var(--border);
  background: #f7fafc; font-size: 0.8rem;
}
.lista-orden label { margin: 0; font-weight: 400; color: var(--muted); white-space: nowrap; }
.lista-orden select { flex: 1; width: auto; margin: 0; font-size: 0.8rem; padding: 0.25rem; }
#form-lista { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.lista-lote { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.7rem; border-bottom: 1px solid var(--border); background: #f7fafc; }
.lista-lote .checkbox { margin: 0; font-size: 0.82rem; }
button.mini.peligro { background: var(--peligro); color: #fff; border-color: var(--peligro); }
button.mini.peligro:hover { background: #b02a37; }
button.mini.eliminar { background: var(--naranja); color: #fff; border-color: var(--naranja); }
button.mini.eliminar:hover { background: var(--naranja-osc); }
.lista-correos {
  overflow-y: auto; flex: 1; min-height: 0;
  scrollbar-width: thin; scrollbar-color: #b6bfc9 transparent;
}
.lista-correos::-webkit-scrollbar { width: 10px; }
.lista-correos::-webkit-scrollbar-track { background: #f0f3f6; }
.lista-correos::-webkit-scrollbar-thumb { background: #b6bfc9; border-radius: 5px; border: 2px solid #f0f3f6; }
.lista-correos::-webkit-scrollbar-thumb:hover { background: #94a0ad; }

.fila-wrap {
  position: relative;
  display: flex; align-items: flex-start; gap: 0.4rem;
  padding-left: 0.5rem; border-bottom: 1px solid var(--border);
  border-left: 4px solid transparent;
  /* Fondo opaco para tapar el box-shadow de .panel-foco (borde de qué panel
     tiene el foco del teclado): sin esto, ese azul se filtraba por el
     border-left transparente de cada fila y se veía duplicado en la activa. */
  background: var(--bg);
}
.fila-wrap:hover { background: #f7fafc; }
.fila-wrap .sel { margin-top: 0.75rem; flex: none; }
a.fila { display: block; flex: 1; min-width: 0; padding: 0.5rem 0.7rem 0.5rem 0.2rem; color: var(--text); }
a.fila:hover { text-decoration: none; }

/* Iconos de leído/eliminar: ocupan el lugar de la fecha, solo al pasar el
   mouse (igual que Gmail), para no estorbar la vista normal de la lista. */
.fila-acciones {
  display: none; position: absolute; top: 0.45rem; right: 0.7rem;
  gap: 0.25rem; background: #f7fafc;
}
.fila-wrap.activo .fila-acciones { background: #d2e3ff; }
.fila-wrap:hover .fila-acciones { display: flex; }
.fila-wrap:hover .fila-top .fecha { visibility: hidden; }
.icono-accion {
  width: 1.6rem; height: 1.6rem; padding: 0; display: flex;
  align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 4px; background: #fff;
  font-size: 0.8rem; line-height: 1; cursor: pointer;
}
.icono-accion:hover { background: #e2e8f0; }
.fila-wrap.no-leido .fila-asunto, .fila-wrap.no-leido .de { font-weight: 700; }
.fila-wrap.no-leido .de::before { content: "● "; color: var(--primary); font-size: 0.7rem; }

/* Correo seleccionado: barra lateral azul + fondo destacado */
.fila-wrap.activo {
  background: #dce9ff;
  border-left-color: var(--primary);
}
.fila-wrap.activo:hover { background: #d2e3ff; }
.fila-wrap.activo .fila-asunto { font-weight: 700; color: #06357a; }

/* Cursor de teclado al marcar/desmarcar con Shift + flechas */
.fila-wrap.foco-teclado { outline: 2px dashed var(--primary); outline-offset: -2px; }

/* Paginación */
.paginacion {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--border);
  background: #f7fafc; font-size: 0.82rem; flex: none;
}
.paginacion.pie { border-bottom: 0; border-top: 1px solid var(--border); }
.paginacion a { padding: 0.15rem 0.45rem; border-radius: 4px; }
.paginacion a:hover { background: #e2e8f0; text-decoration: none; }
.paginacion .off { color: #b6bfc9; padding: 0.15rem 0.45rem; }
.pag-actual { color: var(--muted); }
.fila-top { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.86rem; }
.fila-top .de { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-top .fecha { flex: none; color: var(--muted); font-size: 0.78rem; }
.fila-asunto { font-size: 0.9rem; margin: 0.1rem 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-asunto .est { color: #f0a500; }
.fila-snippet { font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vacio { padding: 1.2rem; font-size: 0.9rem; }

/* Panel 3 — contenido del correo */
.panel-correo { display: flex; flex-direction: column; }
.sin-correo { padding: 2rem; text-align: center; }
.detalle { display: flex; flex-direction: column; height: 100%; }
.detalle-cab { padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); flex: none; }
.d-asunto { font-size: 1.2rem; margin: 0 0 0.5rem; }
.d-de { font-size: 0.95rem; }
.d-meta { font-size: 0.82rem; margin: 0.3rem 0 0.7rem; }
/* Destinatarios: se recortan a 3 y el resto se despliega bajo demanda,
   para que una lista larga no tape el cuerpo del correo. */
.d-dest { display: flex; gap: 0.35rem; align-items: baseline; margin-bottom: 0.15rem; }
.d-etq { flex: none; font-weight: 600; }
.d-lista { min-width: 0; }
.dest-extra.oculto { display: none; }
.dest-mas {
  background: #eef2f7; color: var(--primary); border: 1px solid var(--border);
  border-radius: 999px; padding: 0 0.5rem; margin-left: 0.3rem;
  font-size: 0.75rem; cursor: pointer; white-space: nowrap;
}
.dest-mas:hover { background: #dbe4ee; }
.d-fecha { margin-top: 0.2rem; }
/* La cabecera nunca ocupa más de un tercio del panel: el cuerpo siempre se ve. */
.detalle-cab { max-height: 42vh; overflow-y: auto; }
.d-acc { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.d-acc form { display: inline; }
.d-acc .btn { font-size: 0.9rem; padding: 0.5rem 0.9rem; }

/* ============ Panel flotante de redacción (esquina inferior derecha) ======= */
.compose {
  position: fixed; right: 1rem; bottom: 0;
  width: min(560px, calc(100vw - 2rem));
  height: min(60vh, 560px);
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
  box-shadow: 0 -2px 22px rgba(0, 0, 0, 0.22);
  z-index: 500;
}
.compose.ampliado { width: min(900px, calc(100vw - 2rem)); height: min(88vh, 900px); }
.compose.minimizado { height: auto; }
.compose.minimizado .compose-cuerpo { display: none; }

.compose-cab {
  display: flex; justify-content: space-between; align-items: center;
  background: #1f2933; color: #fff; padding: 0.5rem 0.8rem;
  border-radius: 9px 9px 0 0; cursor: pointer; flex: none;
}
.compose-titulo { font-size: 0.9rem; font-weight: 600; }
.compose-btns { display: flex; gap: 0.15rem; align-items: center; }
.compose-icono {
  background: none; border: 0; color: #cbd5e1; cursor: pointer;
  font-size: 0.95rem; line-height: 1; padding: 0.25rem 0.45rem; border-radius: 4px;
  text-decoration: none;
}
.compose-icono:hover { background: rgba(255, 255, 255, 0.15); color: #fff; text-decoration: none; }

.compose-cuerpo { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 0.5rem 0.8rem 0.8rem; position: relative; }
.compose-cuerpo.sobre-arrastre::after {
  content: "Suelta para adjuntar"; position: absolute; inset: 0.3rem;
  display: flex; align-items: center; justify-content: center;
  background: rgba(59, 130, 246, 0.08); outline: 2px dashed var(--primary); outline-offset: -2px;
  border-radius: 8px; font-size: 0.9rem; font-weight: 600; color: var(--primary);
  pointer-events: none; z-index: 5;
}
.c-campo { display: flex; align-items: center; gap: 0.5rem; position: relative; border-bottom: 1px solid var(--border); }
.c-campo label { width: 44px; flex: none; margin: 0; font-size: 0.82rem; color: var(--muted); font-weight: 400; }
.c-campo input, .c-campo select {
  flex: 1; border: 0; margin: 0; padding: 0.45rem 0; font-size: 0.9rem; background: none;
}
.c-campo input:focus, .c-campo select:focus { outline: none; }
.c-toggle { background: none; border: 0; color: var(--muted); font-size: 0.75rem; cursor: pointer; padding: 0 0.3rem; }
.c-toggle:hover { background: none; color: var(--primary); }
.c-extra.oculto { display: none; }
.c-toolbar {
  display: flex; align-items: center; gap: 0.35rem; flex: none; flex-wrap: nowrap;
  padding: 0.35rem 0; position: relative;
}
.c-toolbar select {
  border: 1px solid var(--border); border-radius: 5px; background: #fff;
  font-size: 0.78rem; padding: 0.2rem 0.3rem; color: inherit; cursor: pointer;
  max-width: 5.4rem; flex: none;
}
.c-toolbar select:focus { outline: none; border-color: var(--primary); }

/* Selector de color de texto: botón dividido (evita el selector de color
   nativo del navegador, que en varios sistemas se cierra con dificultad y
   hace fácil perder la selección de texto). El lado izquierdo reaplica el
   último color usado; la flecha de la derecha abre la paleta. */
.c-color { position: relative; display: flex; flex: none; }
.c-color-aplicar, .c-color-btn {
  display: flex; align-items: center; border: 1px solid var(--border);
  background: #fff; cursor: pointer; padding: 0.2rem 0.35rem;
}
.c-color-aplicar:hover, .c-color-btn:hover { background: #f2f5f9; }
.c-color-aplicar {
  gap: 0.25rem; border-radius: 5px 0 0 5px; border-right: 0;
}
.c-color-btn {
  border-radius: 0 5px 5px 0; padding: 0.2rem 0.25rem; font-size: 0.65rem; color: var(--muted);
}
.c-color-icono { font-size: 0.85rem; font-weight: 700; line-height: 1; }
.c-color-barra {
  display: block; width: 1.1rem; height: 0.25rem; border-radius: 2px;
  background: #000000; border: 1px solid rgba(0, 0, 0, 0.15);
}
.c-color-popover {
  position: absolute; bottom: 100%; right: 0; margin-bottom: 0.4rem; z-index: 700;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18); padding: 0.55rem;
}
.c-color-popover.oculto { display: none; }
.c-color-grid { display: grid; grid-template-columns: repeat(6, 1.3rem); gap: 0.35rem; }
.c-swatch {
  width: 1.3rem; height: 1.3rem; padding: 0; border-radius: 4px; cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.15);
}
.c-swatch:hover { outline: 2px solid var(--primary); outline-offset: 1px; }
.c-swatch-blanco { border-color: #c7ced6; }
.c-color-personalizado {
  display: flex; align-items: center; justify-content: space-between; gap: 0.4rem;
  margin: 0.5rem 0 0; padding-top: 0.4rem; border-top: 1px solid var(--border);
  font-size: 0.78rem; color: var(--muted); cursor: pointer;
}
.c-color-personalizado input[type="color"] {
  width: 1.6rem; height: 1.6rem; padding: 0; border: 1px solid var(--border); border-radius: 5px;
  background: none; cursor: pointer;
}
.c-texto {
  flex: 1; min-height: 0; margin: 0.5rem 0 0; border: 0; padding: 0.3rem 0; resize: none;
  font: inherit; font-size: 0.9rem; line-height: 1.5; overflow-y: auto;
}
.c-texto:focus { outline: none; }
.c-texto:empty::before { content: attr(data-placeholder); color: var(--muted); }
.c-texto img { max-width: 100%; }
.c-texto blockquote { color: var(--muted); }
.compose-pie { display: flex; align-items: center; gap: 0.8rem; padding-top: 0.6rem; border-top: 1px solid var(--border); flex: none; }

/* Botón de adjuntar: se oculta el input nativo y se estiliza la etiqueta */
.c-adjuntar {
  margin: 0; cursor: pointer; font-size: 0.85rem; font-weight: 400;
  background: #eef2f7; border: 1px solid var(--border); border-radius: 6px;
  padding: 0.45rem 0.7rem; white-space: nowrap;
}
.c-adjuntar:hover { background: #e2e8f0; }
.c-adjuntar input[type=file] {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}

/* Listas de adjuntos (los del original y los recién elegidos) */
.c-adj-orig { flex: none; padding: 0.5rem 0 0; }
.c-adj-orig .checkbox { font-size: 0.82rem; margin: 0 0 0.3rem; }
.c-adj-lista {
  list-style: none; margin: 0; padding: 0.4rem 0.6rem; flex: none;
  background: #f7fafc; border: 1px solid var(--border); border-radius: 6px;
  max-height: 110px; overflow-y: auto; font-size: 0.83rem;
}
.c-adj-lista.oculto { display: none; }
.c-adj-lista.apagada { opacity: 0.45; }
.c-adj-lista li { display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.15rem 0; }
.c-adj-lista li span:first-child, .c-adj-lista li a {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.c-adj-nuevos { margin-top: 0.5rem; border-color: #b6d4fe; background: #f0f6ff; }

/* Sugerencias de direcciones */
.sugerencias {
  position: absolute; top: 100%; left: 44px; right: 0; z-index: 600;
  background: #fff; border: 1px solid var(--border); border-radius: 0 0 6px 6px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.16); max-height: 220px; overflow-y: auto;
}
.sugerencias.oculto { display: none; }
.sug { display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.4rem 0.6rem; cursor: pointer; font-size: 0.85rem; }
.sug:hover, .sug.activa { background: #eef4ff; }
.sug-nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug-mail { color: var(--muted); flex: none; font-size: 0.8rem; }

/* Mi cuenta: barra de hospedaje */
.uso-cab { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.8rem; flex-wrap: wrap; }
.uso-cab h2 { margin: 0; }
.barra-uso {
  height: 22px; background: #e5e9ee; border-radius: 999px; overflow: hidden;
  border: 1px solid var(--border);
}
.barra-relleno {
  height: 100%; background: linear-gradient(90deg, #0d6efd, #4d94ff);
  transition: width 0.3s;
}
.barra-uso.mini { height: 7px; margin-top: 0.25rem; max-width: 160px; }
.barra-relleno.alerta { background: linear-gradient(90deg, #fd7e14, #ffa94d); }
.barra-relleno.llena { background: linear-gradient(90deg, #dc3545, #e35d6a); }
.uso-txt { margin: 0.6rem 0 0.4rem; font-size: 0.9rem; }
.planes { margin-top: 0.8rem; font-size: 0.9rem; }
.planes summary { cursor: pointer; color: var(--primary); padding: 0.3rem 0; }
.planes table { margin-top: 0.5rem; }
tr.plan-actual td { background: #eef4ff; font-weight: 600; }
.dos-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.dos-col .card { margin: 0; }
@media (max-width: 800px) { .dos-col { grid-template-columns: 1fr; } }

/* Cambio de plan */
.planes-cuenta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.8rem; margin-bottom: 1.5rem; }
.plan-op {
  display: flex; flex-direction: column; gap: 0.2rem; align-items: flex-start;
  border: 1px solid var(--border); border-radius: 10px; padding: 0.9rem;
  cursor: pointer; font-weight: 400; margin: 0; position: relative;
}
.plan-op:hover { border-color: var(--primary); }
.plan-op.destacado { border-color: var(--primary); }
.plan-op.actual { background: #eef4ff; }
.plan-op:has(input:checked) { border: 2px solid var(--primary); background: #eef4ff; }
.plan-op input { width: auto; margin: 0 0 0.3rem; }
.plan-op input:disabled ~ * { opacity: 0.55; }
.plan-op-nom { font-weight: 700; }
.plan-op-gb { color: var(--muted); font-size: 0.85rem; }
.plan-op-precio { font-size: 1.3rem; font-weight: 700; margin-top: 0.2rem; }
.plan-op-precio small { font-size: 0.75rem; font-weight: 400; color: var(--muted); }
.plan-op-anual { font-size: 0.78rem; color: var(--muted); }

.periodo-op { display: flex; gap: 1.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.ahorro-badge { background: #d1e7dd; color: #0f5132; border-radius: 999px; padding: 0.05rem 0.5rem; font-size: 0.75rem; font-weight: 600; margin-left: 0.3rem; }

.pago-op {
  display: flex; align-items: center; gap: 0.7rem; font-weight: 400;
  border: 1px solid var(--border); border-radius: 8px; padding: 0.7rem 0.9rem;
  margin-bottom: 0.5rem; cursor: pointer;
}
.pago-op:has(input:checked) { border-color: var(--primary); background: #eef4ff; }
.pago-op input { width: auto; margin: 0; }
.pago-op small { display: block; }

/* Directorio de contactos */
.filtros-contactos { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.filtros-contactos input[type=search] { flex: 1; min-width: 200px; margin: 0; }
.filtros-contactos select { width: auto; margin: 0; }
.acc-fila { display: flex; gap: 0.3rem; align-items: center; white-space: nowrap; }
.acc-fila form { display: inline; }
.peligro-txt { color: var(--peligro); }
.panel-pie { display: flex; gap: 0.8rem; padding: 0.5rem 0.4rem; border-top: 1px solid var(--border); font-size: 0.85rem; }
/* Adjuntos del correo: fichas que abren la vista previa */
.d-adj { margin-top: 0.7rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.adj-chip {
  display: flex; align-items: center; gap: 0.45rem;
  background: #f7fafc; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0.4rem 0.7rem; font-size: 0.85rem; cursor: pointer;
  max-width: 260px;
}
.adj-chip:hover { background: #e7f0ff; border-color: var(--primary); }
.adj-ico { flex: none; font-size: 1rem; }
.adj-nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adj-peso { flex: none; color: var(--muted); font-size: 0.78rem; }

/* Aviso breve tras eliminar (sustituye al recargado de la página) */
.aviso {
  position: fixed; left: 1.2rem; bottom: 1.2rem; z-index: 800;
  background: #1f2933; color: #fff; border-radius: 8px;
  padding: 0.65rem 1rem; font-size: 0.88rem; max-width: min(420px, 88vw);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  transition: opacity 0.2s, transform 0.2s;
}
.aviso.error { background: var(--peligro); }
.aviso-deshacer {
  margin-left: 0.5rem; padding: 0.15rem 0.6rem; border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 5px; background: transparent; color: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
.aviso-deshacer:hover { background: rgba(255, 255, 255, 0.18); }
.fila-wrap.borrando { display: none; }
.aviso.oculto { opacity: 0; transform: translateY(8px); pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .aviso { transition: none; } }

/* Visor de adjuntos sobre la misma página */
.visor {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(15, 23, 32, 0.82);
  display: flex; align-items: center; justify-content: center; padding: 2vh 2vw;
}
.visor.oculto { display: none; }
.visor-caja {
  display: flex; flex-direction: column;
  width: min(1100px, 96vw); height: min(92vh, 900px);
  background: #fff; border-radius: 10px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.visor-cab {
  display: flex; align-items: center; gap: 0.7rem; flex: none;
  padding: 0.6rem 0.9rem; background: #1f2933; color: #fff;
}
.visor-nombre { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visor-peso { color: #cbd5e1; font-size: 0.8rem; flex: none; }
.visor-btns { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; flex: none; }
.visor-btns .btn { font-size: 0.85rem; padding: 0.35rem 0.7rem; }
.visor-cuerpo {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  background: #ececf0; overflow: auto;
}
.visor-medio { max-width: 100%; max-height: 100%; }
img.visor-medio { object-fit: contain; cursor: zoom-in; }
img.visor-medio.visor-zoom { max-width: none; max-height: none; cursor: zoom-out; }
iframe.visor-medio { width: 100%; height: 100%; border: 0; background: #fff; }
video.visor-medio { max-height: 100%; }
audio.visor-medio { width: 80%; }
.visor-sin-vista { padding: 2rem; color: var(--muted); text-align: center; font-size: 0.95rem; }
.visor-zoom-btns { display: flex; align-items: center; gap: 0.2rem; flex: none; }
.visor-zoom-btns.oculto { display: none; }
.visor-zoom-nivel { font-size: 0.78rem; color: #cbd5e1; min-width: 2.6em; text-align: center; }
.d-img { margin-top: 0.7rem; background: #fff3cd; color: #664d03; padding: 0.4rem 0.6rem; border-radius: 6px; font-size: 0.83rem; }
.cuerpo-frame { flex: 1; width: 100%; border: 0; background: #fff; }

@media (max-width: 900px) {
  .mail-app { grid-template-columns: 1fr; grid-auto-rows: minmax(0, auto); height: auto; overflow: visible; }
  main.full { height: auto; }
  .mail-app > * { overflow-y: visible; max-height: 60vh; }
  .cuerpo-frame { min-height: 60vh; }
}
