:root {
  --green: #22c55e;
  --green-dark: #16a34a;
  --green-light: #dcfce7;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f4f6f8;
  --card: #ffffff;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warn-bg: #fffbeb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.04);
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

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

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; }
.brand {
  font-weight: 800; font-size: 1.1rem; margin: 2px 8px 22px; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px; color: var(--ink);
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  display: flex; align-items: center; justify-content: center; font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}
.hamburger {
  display: none; background: none; border: 1px solid var(--border); border-radius: 8px;
  font-size: 1.1rem; padding: 6px 10px; cursor: pointer; margin-bottom: 14px;
}
.sidebar nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.sidebar nav a {
  color: #334155;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.89rem;
  font-weight: 500;
  display: flex; align-items: center; gap: 9px;
  border-left: 3px solid transparent;
  transition: background .12s, color .12s;
}
.sidebar nav a .nav-ic { font-size: 0.95rem; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar nav a:hover { background: #f8fafc; text-decoration: none; }
.sidebar nav a.active {
  background: var(--green-light); color: var(--green-dark); font-weight: 700;
  border-left-color: var(--green-dark);
}
.nav-divider { height: 1px; background: var(--border); margin: 10px 6px; }
.nav-section-label {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 14px 10px 4px; opacity: 0.8;
}
.nav-section-label:first-of-type { margin-top: 10px; }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.me { display: flex; flex-direction: column; font-size: 0.82rem; line-height: 1.3; }
.me span { color: var(--muted); }

.content { flex: 1; padding: 28px 34px; max-width: 1240px; }

h1 { font-size: 1.5rem; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 0 0 12px; letter-spacing: -0.005em; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 10px; }
.subtitle { color: var(--muted); margin: 0 0 20px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat .num { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; }
.stat .label { color: var(--muted); font-size: 0.84rem; margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--green); color: #fff; border: none;
  padding: 9px 16px; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 600;
  cursor: pointer; text-decoration: none; box-shadow: 0 1px 2px rgba(22, 163, 74, 0.25);
  transition: background .12s, transform .05s, box-shadow .12s;
}
.btn:hover { background: var(--green-dark); text-decoration: none; box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3); }
.btn:active { transform: translateY(1px); }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: #f8fafc; box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); box-shadow: none; }
.btn-ghost:hover { box-shadow: none; }
.btn-danger { background: var(--danger); box-shadow: 0 1px 2px rgba(220, 38, 38, 0.25); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-lg { padding: 13px 26px; font-size: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; }

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

form.inline { display: inline; }

label { display: block; font-size: 0.85rem; font-weight: 600; margin: 12px 0 5px; }
label:first-child { margin-top: 0; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=color],
select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.92rem; font-family: inherit; background: #fff; color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}
textarea { resize: vertical; min-height: 110px; }
.hint { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 12px 0; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-weight: 500; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: #fafafa; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
  background: #f3f4f6; color: var(--ink);
}
.tag-chip {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 0.72rem;
  font-weight: 600; color: #fff; margin: 0 3px 3px 0;
}

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 0.88rem; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--green-dark); border: 1px solid #bbf7d0; }
.alert-warn { background: var(--warn-bg); color: #92400e; border: 1px solid #fde68a; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: end; }
.filters .field { display: flex; flex-direction: column; gap: 4px; }
.filters label { margin: 0; font-size: 0.75rem; }

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

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

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, #dcfce7, transparent 55%),
              radial-gradient(circle at 80% 85%, #d1fae5, transparent 50%),
              var(--bg);
}
.login-card { background: #fff; padding: 36px; border-radius: 18px; box-shadow: var(--shadow), 0 20px 40px rgba(15,23,42,0.06); width: 350px; border: 1px solid var(--border); }
.login-card h1 { text-align: center; letter-spacing: -0.01em; }
.login-card .brand-icon {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
  box-shadow: 0 6px 16px rgba(22, 163, 74, 0.3);
}

.runner { max-width: 640px; margin: 0 auto; }
.runner-progress { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; color: var(--muted); font-size: 0.85rem; }
.runner-progress-bar { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; margin-bottom: 22px; }
.runner-progress-bar > div { height: 100%; background: var(--green); transition: width .2s; }
.contact-card { text-align: center; padding: 26px 20px; }
.contact-card .avatar {
  width: 62px; height: 62px; border-radius: 50%; background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 700;
  margin: 0 auto 12px;
}
.contact-card h2 { margin-bottom: 2px; }
.contact-card .phone { color: var(--muted); margin-bottom: 16px; }
.message-preview {
  background: #ecfdf5; border: 1px solid #bbf7d0; border-radius: 10px; padding: 16px;
  text-align: left; white-space: pre-wrap; font-size: 0.92rem; margin-bottom: 16px;
}
.attachment-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.attachment-row img { max-height: 130px; border-radius: 8px; border: 1px solid var(--border); }
.runner-actions { display: flex; flex-direction: column; gap: 10px; }
.runner-actions .row { display: flex; gap: 10px; }
.runner-actions .row .btn { flex: 1; }
.copy-feedback { font-size: 0.78rem; color: var(--green-dark); min-height: 16px; margin-top: 4px; }

.done-card { text-align: center; padding: 60px 20px; }
.done-card .big-check { font-size: 3rem; margin-bottom: 10px; }

.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.tag-toggle {
  --chip-color: #6b7280;
  border: 1.5px solid var(--chip-color);
  background: #fff; color: var(--chip-color);
  padding: 4px 12px; border-radius: 999px; font-size: 0.8rem; font-weight: 600;
  cursor: pointer;
}
.tag-toggle.on { background: var(--chip-color); color: #fff; }
.tag-picker-add { display: flex; gap: 8px; margin-top: 4px; }
.tag-picker-add input { flex: 1; }

.emoji-picker { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: #fafafa; margin: 6px 0 4px; max-height: 140px; overflow-y: auto; }
.emoji-btn { border: none; background: transparent; font-size: 1.25rem; padding: 4px 6px; border-radius: 6px; cursor: pointer; line-height: 1; }
.emoji-btn:hover { background: #e5e7eb; }
.emoji-toggle-row { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 0; }

.pipeline-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.pipeline-col { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); width: 260px; flex-shrink: 0; display: flex; flex-direction: column; max-height: calc(100vh - 150px); }
.pipeline-col-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 0.9rem; }
.pipeline-col-body { padding: 10px; overflow-y: auto; flex: 1; min-height: 60px; }
.pipeline-col-body.drag-over { background: #f0fdf4; }
.pipeline-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  margin-bottom: 8px; cursor: grab; font-size: 0.85rem;
}
.pipeline-card.dragging { opacity: 0.4; }
.pipeline-card-name { display: block; font-weight: 600; margin-bottom: 2px; }
.pipeline-card-phone { color: var(--muted); font-size: 0.78rem; }
.pipeline-card-date { color: var(--muted); font-size: 0.72rem; margin-top: 2px; }
.pipeline-card-move { width: 100%; margin-top: 8px; font-size: 0.75rem; padding: 4px 6px; }

/* --- WhatsApp: shell de dos paneles tipo WhatsApp Web --- */
.wa-shell {
  display: flex; height: calc(100vh - 56px); margin: -28px -34px; background: #fff;
  border-top: 1px solid var(--border);
}
.wa-list-pane {
  width: 340px; flex-shrink: 0; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; background: #fff;
}
.wa-list-header { padding: 16px 16px 10px; }
.wa-list-header h1 { margin-bottom: 10px; }
.wa-search {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 20px;
  font-size: 0.88rem; background: var(--bg);
}
.wa-list { flex: 1; overflow-y: auto; }
.wa-item {
  width: 100%; display: flex; gap: 10px; align-items: center; text-align: left;
  padding: 10px 14px; border: none; background: none; border-bottom: 1px solid #f3f4f6; cursor: pointer;
}
.wa-item:hover { background: #f7f8fa; }
.wa-item.active { background: #ecfdf5; }
.wa-avatar {
  width: 42px; height: 42px; border-radius: 50%; background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; font-size: 1rem;
}
.wa-item-body { min-width: 0; flex: 1; }
.wa-item-row { display: flex; justify-content: space-between; gap: 6px; }
.wa-item-name { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-item-time { color: var(--muted); font-size: 0.72rem; flex-shrink: 0; }
.wa-item-preview { color: var(--muted); font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.wa-thread-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #e9edf1; }
.wa-thread-empty { flex: 1; display: flex; align-items: center; justify-content: center; }
.wa-thread { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.wa-thread[hidden], .wa-thread-empty[hidden] { display: none; }
.wa-detail-pane[hidden] { display: none; }
.wa-thread-header {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px; background: #fff;
  border-bottom: 1px solid var(--border);
}
.wa-back { display: none; background: none; border: none; font-size: 1.2rem; cursor: pointer; padding: 4px 8px; }
.wa-thread-name { font-weight: 700; }
.wa-thread-phone { margin: 0; }
.wa-info-toggle {
  margin-left: auto; background: none; border: 1px solid var(--border); border-radius: 50%;
  width: 32px; height: 32px; cursor: pointer; font-size: 1rem; color: var(--muted);
}
.wa-info-toggle:hover { background: #f3f4f6; }

.wa-detail-pane {
  width: 280px; flex-shrink: 0; border-left: 1px solid var(--border); background: #fff;
  display: flex; flex-direction: column;
}
.wa-detail-header {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.wa-detail-close { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 0.95rem; }
.wa-detail-body { flex: 1; overflow-y: auto; padding: 18px 16px; }
.wa-detail-contact { text-align: center; padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.wa-avatar-lg { width: 56px; height: 56px; font-size: 1.3rem; margin: 0 auto 8px; }
.wa-detail-name { font-weight: 700; }
.wa-detail-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; font-size: 0.88rem; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.wa-detail-section { margin-bottom: 18px; }
.wa-detail-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 8px; }

.wa-switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.wa-switch input { opacity: 0; width: 0; height: 0; }
.wa-switch-track {
  position: absolute; inset: 0; background: #d1d5db; border-radius: 999px; cursor: pointer; transition: background .15s;
}
.wa-switch-track::before {
  content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s;
}
.wa-switch input:checked + .wa-switch-track { background: var(--green); }
.wa-switch input:checked + .wa-switch-track::before { transform: translateX(16px); }

.wa-status-opt { display: flex; align-items: center; gap: 8px; padding: 6px 2px; font-size: 0.88rem; cursor: pointer; }
.wa-status-opt input { width: auto; margin: 0; }

.wa-note { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-top: 8px; }
.wa-note-text { font-size: 0.85rem; white-space: pre-wrap; }
.wa-note-meta { color: var(--muted); font-size: 0.7rem; margin-top: 4px; }
.wa-orders { background: #fffbeb; border-bottom: 1px solid #fde68a; padding: 8px 18px; font-size: 0.82rem; }
.wa-order { padding: 2px 0; }

.wa-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.wa-bubble { max-width: 68%; padding: 7px 10px; border-radius: 9px; font-size: 0.9rem; box-shadow: 0 1px 1px rgba(0,0,0,0.06); }
.wa-bubble-in { align-self: flex-start; background: #fff; border-top-left-radius: 2px; }
.wa-bubble-out { align-self: flex-end; background: #dcf8c6; border-top-right-radius: 2px; }
.wa-bubble-text { white-space: pre-wrap; word-break: break-word; }
.wa-bubble-meta { color: var(--muted); font-size: 0.68rem; margin-top: 3px; text-align: right; }

.wa-compose { display: flex; gap: 10px; padding: 12px 18px; background: #fff; border-top: 1px solid var(--border); align-items: flex-end; }
.wa-compose textarea { flex: 1; min-height: 40px; max-height: 120px; resize: none; border-radius: 20px; padding: 9px 14px; }
.wa-compose .btn { border-radius: 20px; }

@media (max-width: 860px) {
  .wa-shell { margin: -16px; height: calc(100vh - 56px); }
  .wa-list-pane { width: 100%; }
  .wa-thread-pane { display: none; }
  .wa-shell.thread-open .wa-list-pane { display: none; }
  .wa-shell.thread-open .wa-thread-pane { display: flex; }
  .wa-back { display: inline-block; }
  /* El panel de detalles tapa toda la pantalla en celular en vez de ir al
     lado, porque ahí no hay espacio para un tercer panel fijo. */
  .wa-detail-pane:not([hidden]) {
    position: fixed; inset: 0; z-index: 30; width: 100%;
  }
}

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 20;
    padding: 12px 14px; box-shadow: 0 1px 0 var(--border);
  }
  .sidebar-top { margin-bottom: 0; }
  .brand { margin: 0; }
  .hamburger { display: block; margin-bottom: 0; }
  /* Colapsado por defecto: solo se ve la barra con la marca + el botón.
     Al tocar el botón, JS agrega .open y esto se despliega como un menú
     desplegable encima del contenido, sin empujarlo hacia abajo. */
  .sidebar nav, .sidebar-footer { display: none; }
  .sidebar.open nav, .sidebar.open .sidebar-footer {
    display: flex; flex-direction: column;
  }
  .sidebar.open nav { margin-top: 10px; }
  .sidebar.open .sidebar-footer { margin-top: 10px; }
  .sidebar nav a { padding: 12px 10px; font-size: 1rem; }
  .content { padding: 16px; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .actions { flex-wrap: wrap; }
  .page-header .actions .btn { flex: 1; min-width: 120px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters .field { width: 100%; }
  table { font-size: 0.82rem; }
  th, td { padding: 8px 6px; }

  /* Objetivos táctiles más grandes (mínimo ~44px) para botones pequeños
     que en escritorio funcionan bien con mouse pero son difíciles de
     tocar con el dedo con precisión. */
  .emoji-btn { min-width: 44px; min-height: 44px; font-size: 1.4rem; }
  .tag-toggle { padding: 8px 14px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  .btn-sm { padding: 8px 12px; min-height: 38px; }
  .pipeline-card-move { min-height: 40px; }
  select, input[type=date] { min-height: 44px; }
}

/* ============ Buzón de correo (/correo) ============ */
.nav-badge {
  margin-left: auto; background: #dc2626; color: #fff; border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; padding: 1px 7px; line-height: 1.5;
}
.mail-shell {
  display: flex; height: calc(100vh - 56px); margin: -28px -34px; background: #fff;
  border-top: 1px solid var(--border);
}
.mail-list-pane {
  width: 380px; flex-shrink: 0; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; background: #fff; min-height: 0;
}
.mail-head { padding: 14px 14px 8px; border-bottom: 1px solid var(--border); }
.mail-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.mail-title-row h1 { margin: 0; }
.mail-title-actions { display: flex; gap: 6px; }
.mail-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.mail-tab {
  flex-shrink: 0; border: 1px solid var(--border); background: #fff; color: var(--ink); border-radius: 999px;
  padding: 6px 12px; font-size: 0.85rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.mail-tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.mail-badge { background: #dc2626; color: #fff; border-radius: 999px; font-size: 0.68rem; padding: 0 6px; line-height: 1.5; }
.mail-address { margin: 2px 2px 8px; font-size: 0.78rem; }
.mail-search { width: 100%; margin-bottom: 8px; }
.mail-filters { display: flex; gap: 6px; overflow-x: auto; }
.mail-filters button {
  border: 1px solid var(--border); background: #fff; color: var(--muted); border-radius: 8px; padding: 5px 10px;
  font-size: 0.8rem; cursor: pointer; white-space: nowrap;
}
.mail-filters button.active { background: var(--green-light); color: var(--green-dark); border-color: var(--green); font-weight: 700; }
.mail-banner { background: var(--warn-bg); border-bottom: 1px solid #fde68a; padding: 8px 14px; font-size: 0.8rem; }
.mail-list { flex: 1; overflow-y: auto; min-height: 0; }
.mail-item {
  display: block; width: 100%; text-align: left; border: none; border-bottom: 1px solid var(--border); background: #fff;
  padding: 11px 14px; cursor: pointer; font: inherit; color: inherit;
}
.mail-item:hover { background: #f7f8fa; }
.mail-item.active { background: #ecfdf5; }
.mail-item.unread .mail-item-who, .mail-item.unread .mail-item-subject { font-weight: 800; }
.mail-item-row { display: flex; justify-content: space-between; gap: 8px; }
.mail-item-who { font-size: 0.92rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-item-time { color: var(--muted); font-size: 0.72rem; flex-shrink: 0; }
.mail-item-subject { font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.mail-item-snippet { color: var(--muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.mail-item-meta { display: flex; gap: 8px; align-items: center; margin-top: 5px; }
.mail-pill { font-size: 0.68rem; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.mail-pill.new { background: #fee2e2; color: #b91c1c; }
.mail-pill.pend { background: #fef3c7; color: #92400e; }
.mail-pill.done { background: #e2e8f0; color: #475569; }
.mail-count { color: var(--muted); font-size: 0.72rem; }

.mail-thread-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #f4f6f8; min-height: 0; }
.mail-thread-empty { flex: 1; display: flex; align-items: center; justify-content: center; }
.mail-thread { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.mail-thread[hidden], .mail-thread-empty[hidden], .mail-reply[hidden] { display: none; }
.mail-thread-header { display: flex; align-items: center; gap: 10px; padding: 12px 18px; background: #fff; border-bottom: 1px solid var(--border); }
.mail-thread-title { flex: 1; min-width: 0; }
.mail-thread-subject { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-thread-sub { margin: 0; font-size: 0.8rem; }
.mail-back { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; padding: 4px 8px; }
.mail-messages { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.mail-msg { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow-sm); }
.mail-msg.out { border-left: 4px solid var(--green); background: #f7fef9; }
.mail-msg-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; font-size: 0.88rem; }
.mail-msg-head .hint { margin: 0; font-size: 0.76rem; word-break: break-all; }
.mail-text { white-space: pre-wrap; word-break: break-word; font: inherit; margin: 0; font-size: 0.9rem; }
.mail-frame { width: 100%; border: 1px solid var(--border); border-radius: 8px; background: #fff; min-height: 80px; }
.mail-msg-tools { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.mail-attachments { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.mail-chip { background: #f1f5f9; border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px; font-size: 0.8rem; color: var(--ink); text-decoration: none; }
.mail-chip.off { color: var(--muted); }
.mail-reply { background: #fff; border-top: 1px solid var(--border); padding: 12px 18px 14px; }
.mail-reply-label { display: block; font-size: 0.8rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.mail-reply textarea { width: 100%; resize: vertical; min-height: 70px; max-height: 240px; }
.mail-reply-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }
.mail-reply-row .hint { margin: 0; font-size: 0.78rem; }
.mail-dialog { border: 1px solid var(--border); border-radius: 14px; padding: 20px; width: min(520px, 92vw); box-shadow: var(--shadow); }
.mail-dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.mail-dialog label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 10px; }
.mail-dialog input, .mail-dialog textarea { width: 100%; margin-top: 4px; }
.mail-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 860px) {
  .mail-shell { margin: -16px; height: calc(100vh - 56px); }
  .mail-list-pane { width: 100%; }
  .mail-thread-pane { display: none; }
  .mail-shell.thread-open .mail-list-pane { display: none; }
  .mail-shell.thread-open .mail-thread-pane { display: flex; }
  .mail-back { display: inline-block; }
  .mail-thread-header { padding: 10px 12px; }
  .mail-messages { padding: 12px; }
  .mail-reply { padding: 10px 12px 12px; }
}

/* Etapa 1: adjuntos con vista previa y aviso de correo nuevo */
.mail-att {
  display: flex; flex-direction: column; gap: 6px; background: #f8fafc; border: 1px solid var(--border);
  border-radius: 10px; padding: 8px; max-width: 260px; min-width: 150px;
}
.mail-att.off { background: #f1f5f9; max-width: 340px; }
.mail-att-thumb { display: block; background: #fff; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.mail-att-thumb img { display: block; width: 100%; max-height: 180px; object-fit: contain; background: #fff; }
.mail-att-name { font-size: 0.8rem; font-weight: 600; word-break: break-all; }
.mail-att-note { font-size: 0.74rem; color: var(--muted); }
.mail-att-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mail-toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 50; max-width: 92vw;
  background: var(--ink); color: #fff; border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px; font-size: 0.9rem;
}
.mail-toast[hidden] { display: none; }
@media (max-width: 860px) {
  .mail-att { max-width: 100%; flex: 1 1 100%; }
  .mail-att-actions .btn { flex: 1; justify-content: center; min-height: 40px; }
}

/* Etapa 2: redactor con formato, Cc/Cco, adjuntos y firma */
.mail-field { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 8px; }
.mail-field input { width: 100%; margin-top: 4px; }
.mail-cc-toggle { margin-bottom: 6px; }
.mail-cc-row[hidden] { display: none; }
.mail-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.mail-tool { border: 1px solid var(--border); background: #f8fafc; border-radius: 8px; padding: 4px 10px; font-size: 0.82rem; cursor: pointer; min-height: 32px; }
.mail-tool.bold { font-weight: 800; }
.mail-tool:hover { background: #eef2f7; }
.mail-dialog textarea, .mail-reply textarea { width: 100%; }
.mail-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.mail-chip { display: inline-flex; align-items: center; gap: 6px; background: #eef2f7; border: 1px solid var(--border); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 0.78rem; max-width: 100%; }
.mail-chip-x { border: 0; background: #cbd5e1; border-radius: 50%; width: 22px; height: 22px; line-height: 20px; cursor: pointer; font-size: 1rem; padding: 0; }
.mail-sig-row { display: flex !important; align-items: center; gap: 4px; font-size: 0.78rem !important; font-weight: 500 !important; color: var(--muted); margin: 8px 0 0 !important; }
.mail-sig-row[hidden] { display: none !important; }
.mail-sig-row input { width: auto !important; margin: 0 !important; }
.mail-fwd { margin: 0 0 8px 12px; }
@media (max-width: 860px) {
  .mail-tool { min-height: 40px; }
  .mail-dialog { width: 96vw; max-height: 92vh; overflow-y: auto; }
}

/* Etapa 3: búsqueda global, asignar, etiquetas, notas internas y ticket */
.mail-search-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 6px 0 4px; }
.mail-scope { font-size: 0.78rem; color: var(--muted); display: flex; align-items: center; gap: 4px; margin: 0; font-weight: 600; }
.mail-scope input { width: auto; margin: 0; }
.mail-search-row select { font-size: 0.78rem; padding: 3px 6px; max-width: 150px; }
.mail-global-note { margin: 8px 14px 0; }
.mail-pill.box { background: #e0e7ff; color: #3730a3; }
.mail-pill.who { background: #f1f5f9; color: #334155; }
.mail-pill.tk { background: #fef3c7; color: #92400e; }
.mail-label-chip { display: inline-block; color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 0.7rem; font-weight: 700; }
.mail-thread-tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 8px 18px; border-bottom: 1px solid var(--border); background: #fff; }
.mail-tool-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.8rem; font-weight: 600; margin: 0; }
.mail-tool-group select { font-size: 0.82rem; padding: 3px 6px; }
.mail-notes { background: #fffbeb; border-top: 1px solid #fde68a; padding: 6px 18px; font-size: 0.85rem; max-height: 38vh; overflow-y: auto; }
.mail-notes summary { cursor: pointer; font-weight: 700; color: #92400e; padding: 4px 0; }
.mail-note { background: #fff; border: 1px solid #fde68a; border-radius: 8px; padding: 6px 10px; margin: 6px 0; }
.mail-note-text { white-space: pre-wrap; word-break: break-word; }
.mail-note-del { border: 0; background: none; color: #b91c1c; cursor: pointer; font-size: 0.75rem; padding: 0; text-decoration: underline; }
.mail-note-form { display: flex; gap: 8px; align-items: flex-end; margin: 6px 0 8px; }
.mail-note-form textarea { flex: 1; resize: vertical; min-height: 44px; }
.mail-labels-list { max-height: 40vh; overflow-y: auto; margin-bottom: 10px; }
.mail-label-row { display: flex !important; align-items: center; gap: 8px; padding: 4px 0; margin: 0 !important; }
.mail-label-row input { width: auto !important; margin: 0 !important; }
.mail-label-new { display: flex; gap: 6px; flex-wrap: wrap; }
.mail-label-new input { flex: 1; min-width: 140px; }
.mail-alert-check { display: flex !important; gap: 8px; align-items: flex-start; }
.mail-alert-check input { width: auto !important; margin-top: 3px !important; }
@media (max-width: 860px) {
  .mail-thread-tools { padding: 8px 12px; }
  .mail-notes { padding: 6px 12px; }
  .mail-note-form { flex-direction: column; align-items: stretch; }
}

/* Etapa 4: plantillas, archivo y papelera */
.mail-tpl-list { max-height: 36vh; overflow-y: auto; margin-bottom: 10px; }
.mail-tpl-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.mail-tpl-info { flex: 1; min-width: 160px; font-size: 0.85rem; }
.mail-tpl-info .hint { margin: 2px 0 0; }
.mail-danger { color: #b91c1c; }
.mail-filters { flex-wrap: wrap; }

/* ===== Correo v2: riel de buzones, estrellas, avatares y firma con imagen ===== */
.mail-shell { position: relative; }
.mail-rail { width: 226px; flex-shrink: 0; background: #f8fafc; border-right: 1px solid var(--border); padding: 14px 10px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; min-height: 0; }
.mail-compose { width: 100%; justify-content: center; padding: 11px 14px; font-size: 0.95rem; border-radius: 14px; margin-bottom: 8px; box-shadow: var(--shadow-sm); }
.mail-rail-title { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 4px; }
.mail-boxes, .mail-folders, .mail-rail-labels { display: flex; flex-direction: column; gap: 1px; }
.mail-tab, .mail-folders button, .mail-folders a, .mail-rail-labels button {
  border: 0; background: none; border-radius: 10px; padding: 8px 10px; text-align: left; font-size: 0.9rem; font-weight: 600;
  color: var(--ink); cursor: pointer; display: flex; align-items: center; gap: 8px; width: 100%; text-decoration: none; flex-shrink: 1;
}
.mail-tab:hover, .mail-folders button:hover, .mail-folders a:hover, .mail-rail-labels button:hover { background: #eef2f7; }
.mail-tab.active, .mail-folders button.active, .mail-rail-labels button.active { background: var(--green-light); color: var(--green-dark); border: 0; font-weight: 800; }
.mail-tab-name { flex: 1; }
.mail-badge { margin-left: auto; }
.mail-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.mail-rail-empty { padding: 4px 10px; font-size: 0.78rem; margin: 0; }
.mail-rail-btn { display: none; border: 1px solid var(--border); background: #fff; border-radius: 10px; width: 40px; height: 40px; font-size: 1.2rem; cursor: pointer; flex-shrink: 0; }
.mail-rail-scrim { display: none; }
.mail-list-pane { width: 370px; }
.mail-title-row { justify-content: flex-start; gap: 10px; margin-bottom: 10px; }
.mail-title-box h1 { font-size: 1.25rem; margin: 0; line-height: 1.2; }
.mail-title-box .mail-address { margin: 0; }
.mail-item { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; padding: 11px 12px; border: 0; border-bottom: 1px solid #eef1f5; background: #fff; cursor: pointer; font: inherit; }
.mail-item:hover { background: #f7f8fa; }
.mail-item.active { background: #ecfdf5; }
.mail-item.selected { background: #eff6ff; }
.mail-avatar { width: 38px; height: 38px; border-radius: 50%; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.82rem; flex-shrink: 0; user-select: none; }
.mail-avatar.pick { cursor: pointer; }
.mail-item-main { flex: 1; min-width: 0; }
.mail-item-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.mail-item-meta { flex-wrap: wrap; gap: 5px; }
.mail-star { border: 0; background: none; cursor: pointer; font-size: 1.1rem; color: #9ca3af; padding: 0 2px; line-height: 1; }
.mail-star.on, .mail-star-btn.on { color: #f59e0b; }
.mail-star-btn { border: 0; background: none; font-size: 1.5rem; cursor: pointer; color: #9ca3af; line-height: 1; padding: 0 4px; }
.mail-bulk { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 8px 12px; background: #eff6ff; border-bottom: 1px solid #bfdbfe; font-size: 0.85rem; }
.mail-bulk[hidden] { display: none; }
.mail-empty { padding: 28px 16px; text-align: center; }
.mail-linkbtn { border: 0; background: none; color: #2563eb; cursor: pointer; font-size: 0.78rem; text-decoration: underline; padding: 0; margin-left: 8px; font-weight: 600; }
.mail-msg-head { flex-wrap: nowrap; align-items: flex-start; gap: 10px; }
.mail-msg-from { flex: 1; min-width: 0; }
.mail-msg-head > .hint { flex-shrink: 0; }
.mail-search-row { padding: 0 14px; margin: 6px 0 4px; }
.btn.undo { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.mail-sig-img { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: #f8fafc; }
.mail-sig-img-title { font-size: 0.82rem; font-weight: 700; margin-bottom: 8px; }
.mail-sig-img-row { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.mail-sig-preview { width: 150px; min-height: 70px; background: #fff; border: 1px dashed var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 6px; }
.mail-sig-img-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.mail-sig-width { display: flex !important; align-items: center; gap: 6px; font-size: 0.8rem !important; margin: 0 !important; }
.mail-sig-width select { width: auto; margin: 0; }
.mail-rail-tools { margin-top: 2px; }
@media (max-width: 1099px) {
  .mail-rail { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 210; transform: translateX(-104%); transition: transform 0.2s ease; box-shadow: var(--shadow); }
  .mail-shell.rail-open .mail-rail { transform: none; }
  .mail-rail-scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
  .mail-shell.rail-open .mail-rail-scrim { opacity: 1; pointer-events: auto; }
  .mail-rail-btn { display: inline-flex; align-items: center; justify-content: center; }
}
@media (max-width: 860px) {
  .mail-list-pane { width: 100%; }
  .mail-avatar { width: 42px; height: 42px; }
  .mail-msg-head { flex-wrap: wrap; }
}

/* ===== Correo v3: hilo ordenado, mensajes plegables, adjuntos y visor de imágenes ===== */
.mail-thread-pane { background: #f1f5f9; }
.mail-thread-header { align-items: flex-start; padding: 12px 18px; }
.mail-thread-subject { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 1.05rem; line-height: 1.3; }
.mail-thread-sub { margin-top: 2px; white-space: normal; word-break: break-all; }
.mail-thread-tools { flex-wrap: nowrap; overflow-x: auto; gap: 6px 8px; padding: 6px 18px; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.mail-thread-tools .btn { white-space: nowrap; flex-shrink: 0; padding: 5px 10px; font-size: 0.8rem; }
.mail-thread-tools .mail-tool-group { flex-wrap: nowrap; flex-shrink: 0; }
.mail-messages { padding: 14px 18px; gap: 10px; background: #f1f5f9; }
.mail-msg { padding: 0; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); overflow: hidden; background: #fff; }
.mail-msg.out { background: #fff; border-left: 4px solid var(--green); }
.mail-msg-head { padding: 12px 14px; margin: 0; cursor: pointer; align-items: center; }
.mail-msg-head:hover { background: #f8fafc; }
.mail-msg-from { flex: 1; min-width: 0; }
.mail-msg-from strong { display: block; font-size: 0.95rem; }
.mail-msg-sub { margin: 1px 0 0; font-size: 0.78rem; word-break: break-word; }
.mail-msg.collapsed .mail-msg-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-msg-date { font-size: 0.74rem; flex-shrink: 0; white-space: nowrap; }
.mail-msg.collapsed { opacity: 0.92; }
.mail-msg.collapsed .mail-msg-content { display: none; }
.mail-msg-content { padding: 0 14px 12px 14px; border-top: 1px solid #eef1f5; }
.mail-msg-body { padding-top: 12px; }
.mail-frame { border: 0; background: #fff; border-radius: 0; min-height: 60px; }
.mail-text { font-size: 0.92rem; line-height: 1.55; }
.mail-img-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: #f1f5f9; border-radius: 8px; padding: 8px 10px; margin-top: 12px; font-size: 0.82rem; color: #475569; }
.mail-msg-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.mail-atts { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.mail-atts-title { font-size: 0.8rem; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.mail-atts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.mail-att { display: flex; flex-direction: column; gap: 6px; background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 8px; max-width: none; min-width: 0; flex: none; }
.mail-att.pdf, .mail-att.other, .mail-att.off { flex-direction: row; align-items: center; gap: 10px; }
.mail-att-ico { font-size: 1.6rem; flex-shrink: 0; }
.mail-att-info { min-width: 0; flex: 1; }
.mail-att-name { font-size: 0.82rem; font-weight: 700; word-break: break-word; line-height: 1.25; }
.mail-att-note { font-size: 0.74rem; color: var(--muted); }
.mail-att-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.mail-att-actions .btn { padding: 3px 10px; }
.mail-att-thumb { display: block; width: 100%; height: 110px; padding: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; cursor: zoom-in; }
.mail-att-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; max-height: none; }
.mail-att.image .mail-att-info { width: 100%; }
.mail-notes { background: #fff; border-top: 1px solid var(--border); padding: 4px 18px; max-height: 40vh; }
.mail-notes summary { font-size: 0.82rem; color: #92400e; padding: 6px 0; }
.mail-reply { padding: 0; background: #fff; border-top: 1px solid var(--border); }
.mail-reply-bar { display: flex; align-items: center; gap: 8px; padding: 10px 18px; flex-wrap: wrap; }
.mail-reply-bar[hidden], .mail-reply-box[hidden] { display: none; }
.mail-reply-from { margin: 0 0 0 auto; font-size: 0.78rem; }
.mail-reply-box { padding: 10px 18px 14px; max-height: 60vh; overflow-y: auto; }
.mail-reply-x { margin-left: auto; float: right; border: 0; background: #f1f5f9; border-radius: 50%; width: 26px; height: 26px; cursor: pointer; font-size: 0.85rem; }
/* visor de imágenes */
.mail-lightbox { position: fixed; inset: 0; z-index: 400; background: rgba(8, 12, 22, 0.97); display: flex; align-items: center; justify-content: center; }
.mail-lightbox[hidden] { display: none; }
body.mail-lb-open { overflow: hidden; }
.mail-lb-bar { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; background: linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0)); color: #fff; z-index: 2; }
.mail-lb-title { font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mail-lb-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.mail-lb-x { border: 0; background: #fff; color: #111; width: 42px; height: 42px; border-radius: 50%; font-size: 1.25rem; font-weight: 700; cursor: pointer; line-height: 1; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.mail-lb-x:hover { background: #fee2e2; color: #b91c1c; }
.mail-lb-stage { max-width: 100vw; max-height: 100vh; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 60px 56px 40px; }
.mail-lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; background: #fff; cursor: zoom-in; }
.mail-lb-stage img.zoom { max-width: none; max-height: none; cursor: zoom-out; }
.mail-lb-nav { position: absolute; top: 50%; transform: translateY(-50%); border: 0; background: rgba(255,255,255,0.9); width: 44px; height: 64px; border-radius: 10px; font-size: 2rem; cursor: pointer; z-index: 2; line-height: 1; }
.mail-lb-nav[hidden] { display: none; }
.mail-lb-nav.prev { left: 8px; } .mail-lb-nav.next { right: 8px; }
.mail-lb-count { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; color: #e5e7eb; font-size: 0.82rem; }
@media (max-width: 860px) {
  .mail-thread-header { padding: 10px 12px; }
  .mail-thread-tools { padding: 6px 12px; }
  .mail-messages { padding: 10px; }
  .mail-msg-head { padding: 10px 12px; flex-wrap: nowrap; }
  .mail-msg-date { display: none; }
  .mail-msg-content { padding: 0 12px 12px; }
  .mail-atts-grid { grid-template-columns: 1fr 1fr; }
  .mail-reply-bar { padding: 8px 12px; }
  .mail-reply-from { display: none; }
  .mail-reply-bar .btn { flex: 1; justify-content: center; }
  .mail-reply-box { padding: 8px 12px 12px; }
  .mail-lb-stage { padding: 56px 8px 36px; }
  .mail-lb-nav { width: 38px; height: 54px; }
}
.app-shell > .content { min-width: 0; }
.mail-thread-pane, .mail-thread, .mail-thread-tools { min-width: 0; max-width: 100%; }
.mail-thread-tools { flex-wrap: wrap; overflow-x: visible; }
.mail-thread-tools .mail-tool-group { flex-wrap: wrap; }
@media (max-width: 860px) {
  .mail-thread-tools { flex-wrap: nowrap; overflow-x: auto; }
  .mail-thread-tools .mail-tool-group, .mail-thread-tools .btn { flex-shrink: 0; white-space: nowrap; }
  .mail-thread-subject { font-size: 1rem; }
  #mail-done-btn { padding: 6px 10px; font-size: 0.78rem; }
}
/* los mensajes nunca se encogen: si no caben, la lista de mensajes hace scroll */
.mail-messages { overflow-y: auto; overflow-x: hidden; }
.mail-msg { flex-shrink: 0; }
.mail-messages > .mail-thread-tools { flex-shrink: 0; border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; }
/* Menú lateral: si la pantalla es baja, el menú se desplaza para poder ver TODAS las opciones */
.sidebar { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.sidebar nav { flex: 1 0 auto; }
.sidebar-footer { flex-shrink: 0; }

/* ===== Notificaciones (campana) ===== */
.notif-wrap { padding: 0; background: #e9edef; }
.notif-feed { max-height: calc(100vh - 330px); min-height: 260px; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.notif-day { text-align: center; margin: 6px 0; }
.notif-day span { background: #fff; color: var(--muted); font-size: 0.74rem; font-weight: 700; padding: 3px 12px; border-radius: 999px; text-transform: capitalize; box-shadow: var(--shadow-sm); }
.notif-bubble { align-self: flex-start; max-width: min(560px, 92%); background: #fff; border-radius: 4px 14px 14px 14px; padding: 9px 12px; box-shadow: var(--shadow-sm); border-left: 4px solid #94a3b8; }
.notif-bubble.is-new { box-shadow: 0 0 0 2px #bbf7d0, var(--shadow-sm); }
.notif-quote { border-left-color: #2563eb; } .notif-order { border-left-color: #16a34a; } .notif-ticket { border-left-color: #dc2626; }
.notif-alert { border-left-color: #f59e0b; } .notif-mail { border-left-color: #7c3aed; } .notif-contact { border-left-color: #0891b2; }
.notif-title { font-weight: 700; font-size: 0.92rem; }
.notif-new { background: #16a34a; color: #fff; border-radius: 999px; font-size: 0.65rem; padding: 1px 7px; vertical-align: middle; }
.notif-body { white-space: pre-wrap; word-break: break-word; font-size: 0.88rem; margin-top: 3px; color: #334155; }
.notif-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.notif-meta .hint { margin: 0; font-size: 0.72rem; }

/* ============ Avisos en el celular (push) ============ */
.push-card { max-width: 560px; }
.push-big { width: 100%; justify-content: center; font-size: 1.05rem; padding: 14px 18px; min-height: 52px; }
.push-steps { padding-left: 20px; line-height: 1.7; }
.push-steps li { margin-bottom: 6px; }
.push-msg { margin-top: 12px; font-weight: 600; }
.push-msg.good { color: #166534; }
.push-msg.bad { color: #991b1b; }
.push-devices { list-style: none; margin: 0; padding: 0; }
.push-devices li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.push-devices li:last-child { border-bottom: 0; }
.push-banner { display: flex; align-items: center; gap: 8px; background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.push-banner a { flex: 1; color: inherit; font-weight: 600; }
.push-banner button { background: transparent; border: 0; font-size: 1.1rem; color: inherit; min-width: 36px; min-height: 36px; cursor: pointer; }

/* Celular: el menú desplegado puede ser más largo que la pantalla; que haga scroll para ver todas las opciones. */
@media (max-width: 760px) {
  .sidebar.open { max-height: 100vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .sidebar.open nav { flex: 0 0 auto; }
}
