/* Webmail · Es+ Creatividad Aplicada */

/* Fuentes incluidas (SIL Open Font License, ver fonts/OFL-*.txt). Subconjunto latino: cubre el español. */
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/poppins-400.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/poppins-500.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/poppins-600.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/poppins-700.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/space-grotesk-500.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/space-grotesk-600.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/space-grotesk-700.woff2") format("woff2"); }

:root {
  --brand: #4252ff;
  --brand-hover: #3442ea;
  --brand-ink: #ffffff;
  --brand-soft: #eef0ff;
  --navy: #101737;
  --sky: #7cc4ff;
  --bg: #f5f6fa;
  --panel: #ffffff;
  --panel-2: #f8f9fc;
  --text: #161a2e;
  --muted: #747a90;
  --line: #e6e8f0;
  --unread: #101737;
  --danger: #d12f3f;
  --ok: #0d8a5f;
  --star: #f5a524;
  --shadow: 0 12px 32px rgba(16, 23, 55, .10);
  --shadow-sm: 0 1px 2px rgba(16, 23, 55, .04);
  --radius: 10px;
  --rail: 96px;
  --font: "Poppins", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-head: "Space Grotesk", "Poppins", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #5866ff;
    --brand-hover: #6b78ff;
    --brand-soft: #222a52;
    --bg: #0e1020;
    --panel: #161a2e;
    --panel-2: #1c2138;
    --text: #e7e9f3;
    --muted: #9aa0b8;
    --line: #272c45;
    --unread: #ffffff;
    --danger: #ff6b78;
    --ok: #36d39a;
    --shadow: 0 12px 32px rgba(0, 0, 0, .45);
    --shadow-sm: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-head); letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }

.ico { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ico svg { width: 100%; height: 100%; }

/* ---------------------------------------------------------------- botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); cursor: pointer; white-space: nowrap; font-weight: 500; transition: background .15s, border-color .15s, filter .15s;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.light { background: #fff; border-color: #fff; color: var(--brand); font-weight: 600; }
.btn.light:hover { background: var(--brand-soft); }
.btn.ghost-light { background: transparent; border-color: rgba(255, 255, 255, .55); color: #fff; }
.btn.ghost-light:hover { background: rgba(255, 255, 255, .12); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.lg { padding: 14px 18px; font-size: 15px; }
.btn:disabled { opacity: .6; cursor: default; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.link { border: 0; background: none; color: var(--brand); cursor: pointer; padding: 0 4px; font-weight: 500; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.spinner {
  display: inline-block; width: 18px; height: 18px; margin-right: 8px; vertical-align: -4px;
  border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot { display: grid; place-items: center; height: 100vh; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.avatar { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-family: var(--font-head); }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }

/* ---------------------------------------------------------------- login */
.is-login { background: var(--panel); }
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 40px 16px; }
.login-logo img { display: block; width: 170px; height: auto; }
.login-card {
  width: 100%; max-width: 380px; padding: 36px 32px 32px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 18px;
}
.login-title { margin: 0 0 8px; font-size: 32px; line-height: 1.2; text-align: center; font-weight: 700; color: var(--text); }
.login-field { display: grid; gap: 7px; }
.login-field label { font-size: 13px; color: var(--muted); }
.login-field input {
  height: 54px; padding: 0 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.login-field input::placeholder { color: #9aa0b3; }
.login-field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.login-card .btn { margin-top: 8px; }
.login-error { padding: 10px 14px; border-radius: 6px; background: rgba(209, 47, 63, .08); color: var(--danger); font-size: 13px; }
.login-foot { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- estructura */
.shell { display: flex; height: 100vh; }
.rail {
  flex: none; width: var(--rail); display: flex; flex-direction: column; align-items: stretch; gap: 4px;
  padding: 18px 0 14px; background: var(--brand); color: #fff; z-index: 45;
}
.rail-logo { display: grid; place-items: center; padding: 0 18px 20px; }
.rail-logo img { width: 56px; height: auto; display: block; }
.rail-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 13px 4px;
  border: 0; background: transparent; color: rgba(255, 255, 255, .85); cursor: pointer; font-size: 12.5px; font-weight: 500;
}
.rail-item .ico { width: 22px; height: 22px; }
.rail-item:hover { background: rgba(255, 255, 255, .10); color: #fff; }
.rail-item.active { background: rgba(16, 23, 55, .18); color: #fff; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 22px 28px 18px; }
.page-title { margin: 0; font-size: 28px; line-height: 1.15; font-weight: 700; }
.crumbs { display: flex; gap: 6px; margin-top: 4px; color: var(--muted); font-size: 12.5px; }
.crumb-sep { opacity: .6; }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.user-mail { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.drawer-btn { display: none !important; }
.workspace {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 250px minmax(320px, 400px) minmax(0, 1fr);
  gap: 20px; padding: 0 28px 24px;
}

/* columna lateral: tarjeta azul + carpetas */
.side-col { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; }
.hello-card { padding: 20px; border-radius: var(--radius); background: var(--brand); color: #fff; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.hello-kicker { margin: 0; font-size: 12px; opacity: .8; text-transform: uppercase; letter-spacing: .06em; }
.hello-user { margin: 4px 0 6px; font-family: var(--font-head); font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.hello-meta { margin: 0 0 16px; font-size: 13px; opacity: .9; }
.hello-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hello-actions .btn { padding: 7px 12px; font-size: 13px; }
.side-title { margin: 0 4px 4px; font-size: 15px; font-weight: 600; }
.folders { display: flex; flex-direction: column; gap: 2px; }
.folder {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px 8px calc(10px + var(--depth, 0) * 16px);
  border: 0; border-radius: 6px; background: transparent; text-align: left; cursor: pointer; color: var(--text);
}
.folder .ico { color: var(--muted); }
.folder:hover { background: var(--panel); }
.folder.active { background: var(--panel); color: var(--brand); font-weight: 600; box-shadow: inset 3px 0 0 var(--brand), var(--shadow-sm); }
.folder.active .ico { color: var(--brand); }
.folder-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 600; text-align: center; line-height: 20px; }

/* lista */
.list-card { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.search { display: flex; align-items: center; gap: 8px; margin: 14px 14px 6px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 10px 0; outline: none; color: var(--text); }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 10px; border-bottom: 1px solid var(--line); }
.check-all { margin: 0 8px 0 6px; accent-color: var(--brand); }
.bulk { display: flex; align-items: center; gap: 2px; }
.bulk.disabled select { opacity: .35; }
select.move { max-width: 104px; padding: 5px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--muted); }
.pager { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.pager-info { color: var(--muted); font-size: 12px; margin-right: 4px; white-space: nowrap; }
.msg-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.msg {
  display: grid; grid-template-columns: auto auto 1fr; align-items: start; gap: 4px 8px;
  padding: 12px 16px 12px 10px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative;
}
.msg:hover { background: var(--panel-2); }
.msg.active, .msg.selected { background: var(--brand-soft); }
.msg.unread::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); }
.msg input { margin: 3px 0 0 6px; accent-color: var(--brand); }
.star { border: 0; background: none; padding: 0; color: var(--line); cursor: pointer; width: 20px; height: 20px; }
.star .ico { width: 17px; height: 17px; }
.star:hover { color: var(--muted); }
.star.on { color: var(--star); }
.star.on svg { fill: currentColor; }
.msg-main { min-width: 0; }
.msg-top { display: flex; align-items: center; gap: 6px; }
.msg-from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.msg-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13.5px; }
.msg.unread .msg-from, .msg.unread .msg-subject { color: var(--unread); font-weight: 600; }
.clip { color: var(--muted); }
.clip .ico { width: 14px; height: 14px; }
.list-empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.error { color: var(--danger); }

/* lectura */
/* El panel de lectura es siempre claro (también en modo oscuro), como la tarjeta del login:
   los correos están diseñados para fondo blanco. */
.reader {
  --panel: #ffffff; --panel-2: #f8f9fc; --text: #161a2e; --muted: #747a90; --line: #e6e8f0;
  --brand: #4252ff; --brand-hover: #3442ea; --brand-soft: #eef0ff; --danger: #d12f3f;
  overflow-y: auto; min-width: 0; background: var(--panel); color: var(--text); color-scheme: light;
}
.reader-empty { height: 100%; min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); padding: 24px; text-align: center; }
.reader-empty .ico { width: 46px; height: 46px; color: var(--brand); opacity: .35; }
.reader-inner { max-width: 980px; margin: 0 auto; padding: 0 28px 32px; }
.reader-actions { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 2px; padding: 10px 0; background: var(--panel); border-bottom: 1px solid var(--line); }
.reader-subject { font-size: 23px; line-height: 1.25; margin: 22px 0 16px; overflow-wrap: anywhere; }
.reader-from { display: flex; align-items: flex-start; gap: 12px; }
.reader-people { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.from-name { font-weight: 600; }
.reader-date { white-space: nowrap; }
.notice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; padding: 12px 14px; border-radius: 8px; background: var(--brand-soft); color: var(--text); font-size: 13px; }
.notice .ico { color: var(--brand); }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.attachment { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); text-decoration: none; background: var(--panel-2); font-size: 13px; }
.attachment .ico { color: var(--brand); }
.attachment:hover { border-color: var(--brand); }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.mail-body { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.mail-frame { display: block; width: 100%; height: 200px; border: 0; background: #fff; }

/* ---------------------------------------------------------------- redactar */
.compose {
  position: fixed; right: 28px; bottom: 0; z-index: 50; width: min(660px, calc(100vw - 56px)); max-height: calc(100vh - 40px);
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 12px 12px 0 0; box-shadow: var(--shadow);
}
.c-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 18px; background: var(--brand); color: #fff; border-radius: 12px 12px 0 0; }
.c-head strong { font-family: var(--font-head); font-weight: 600; }
.c-head .icon-btn { color: rgba(255, 255, 255, .85); }
.c-head .icon-btn:hover { background: rgba(255, 255, 255, .15); color: #fff; }
.c-fields { padding: 0 18px; }
.c-field { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.c-field > span:first-child { width: 52px; color: var(--muted); flex: none; font-size: 13px; }
.c-field input { flex: 1; min-width: 0; padding: 11px 0; border: 0; background: transparent; outline: none; }
.c-toggles { display: flex; gap: 4px; }
.c-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 1px; padding: 5px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.c-tools .icon-btn { width: 30px; height: 30px; }
.c-tools .icon-btn .ico { width: 16px; height: 16px; }
.c-tools .icon-btn.on { background: var(--brand-soft); color: var(--brand); }
.c-sep { width: 1px; height: 18px; margin: 0 5px; background: var(--line); }
.c-editor { flex: 1; min-height: 220px; overflow-y: auto; padding: 14px 18px; outline: none; line-height: 1.6; overflow-wrap: anywhere; cursor: text; }
.c-editor p { margin: 0 0 .6em; }
.c-editor ul, .c-editor ol { margin: 0 0 .6em; padding-left: 1.6em; }
.c-editor blockquote { margin: 0 0 .6em .2em; padding-left: .9em; border-left: 3px solid var(--brand); color: var(--muted); }
.c-editor a { color: var(--brand); }
.c-editor img { max-width: 100%; height: auto; }
.c-editor table { max-width: 100%; border-collapse: collapse; }
.c-editor pre { white-space: pre-wrap; }
.c-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px; }
.c-files:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; background: var(--brand-soft); font-size: 13px; max-width: 100%; }
.chip .ico { width: 14px; height: 14px; color: var(--brand); }
.chip-x { border: 0; background: none; cursor: pointer; font-size: 16px; line-height: 1; color: var(--muted); padding: 0 4px; }
.c-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); margin-top: 8px; }
.c-status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-foot .spacer { flex: 1; }

/* ---------------------------------------------------------------- contactos */
.contacts-card, .contact-pane { display: none; }
.view-contacts .list-card, .view-contacts .reader { display: none; }
.view-contacts .contacts-card { display: flex; }
.view-contacts .contact-pane { display: block; }
.side-title.spaced { margin-top: 18px; }
.view-contacts .folders .folder.active { background: transparent; color: var(--text); font-weight: 400; box-shadow: none; }
.view-contacts .folders .folder.active .ico { color: var(--muted); }
.contacts-card { flex-direction: column; min-height: 0; overflow: hidden; }
.cc-head { display: flex; align-items: center; gap: 8px; padding: 14px; border-bottom: 1px solid var(--line); }
.cc-head .search { flex: 1; margin: 0; }
.cc-head .btn { padding: 9px 14px; }
.contact-list { list-style: none; margin: 0; padding: 0 0 8px; overflow-y: auto; flex: 1; }
.c-letter { position: sticky; top: 0; z-index: 1; padding: 8px 18px 4px; background: var(--panel); color: var(--brand); font-family: var(--font-head); font-weight: 700; font-size: 13px; }
.contact { display: flex; align-items: center; gap: 12px; padding: 10px 18px; cursor: pointer; }
.contact:hover { background: var(--panel-2); }
.contact.active { background: var(--brand-soft); }
.contact-main { min-width: 0; }
.contact-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-pane { overflow-y: auto; min-width: 0; }
.contact-detail, .contact-form { max-width: 640px; margin: 0 auto; padding: 0 28px 32px; }
.cd-actions { display: flex; align-items: center; gap: 4px; min-height: 55px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cd-head { display: flex; align-items: center; gap: 18px; margin: 26px 0 18px; }
.cd-title { min-width: 0; }
.cd-name { margin: 0; font-size: 24px; line-height: 1.2; overflow-wrap: anywhere; }
.cd-head p { margin: 4px 0 0; }
.avatar.xl { width: 72px; height: 72px; font-size: 24px; }
.avatar.xs { width: 26px; height: 26px; font-size: 10px; }
.cd-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.cd-buttons a.btn { text-decoration: none; color: var(--text); }
.cd-rows { display: grid; gap: 4px; border-top: 1px solid var(--line); padding-top: 12px; }
.cd-row { display: flex; gap: 14px; padding: 10px 0; }
.cd-row > .ico { color: var(--brand); margin-top: 2px; }
.cd-value { min-width: 0; overflow-wrap: anywhere; }
.cd-label { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.cd-value a { color: var(--brand); text-decoration: none; }
.cd-value a:hover { text-decoration: underline; }
.cd-notes { margin: 0; white-space: pre-wrap; }
.cf-title { margin: 0; font-size: 18px; }
.contact-form { display: grid; gap: 14px; }
.contact-form .cd-actions { margin-bottom: 8px; }
.cf-field { display: grid; gap: 6px; }
.cf-field span { font-size: 13px; color: var(--muted); }
.cf-field input, .cf-field textarea { padding: 11px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); resize: vertical; }
.cf-field input:focus, .cf-field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.cf-buttons { display: flex; gap: 8px; margin-top: 6px; }
.contact-link { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; font-size: 12.5px; vertical-align: 1px; }
.contact-link .ico { width: 14px; height: 14px; }
.link:disabled { opacity: .5; cursor: default; }

/* autocompletar destinatarios */
.c-field { position: relative; }
.ac-list {
  position: absolute; left: 52px; right: 0; top: 100%; z-index: 5; margin: 2px 0 0; padding: 6px; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); max-height: 300px; overflow-y: auto;
}
.ac-list li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.ac-list li.on, .ac-list li:hover { background: var(--brand-soft); }
.ac-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ac-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-mail { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }

/* ---------------------------------------------------------------- carpetas: menú y arrastrar */
.side-title-row { display: flex; align-items: center; justify-content: space-between; margin: 0 0 4px; }
.side-title-row .side-title { margin: 0 4px; }
.side-title-row .icon-btn { width: 28px; height: 28px; }
.folder-row { position: relative; }
.folder-more { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; opacity: 0; }
.folder-row:hover .folder-more, .folder-more:focus-visible { opacity: 1; background: var(--panel); }
.folder-row:hover .badge { visibility: hidden; }
.folder.drop { background: var(--brand-soft) !important; color: var(--brand); box-shadow: inset 0 0 0 2px var(--brand) !important; }
.dragging-mail .folder { transition: background .1s; }
.msg.dragging { opacity: .5; }
.pop-menu { position: fixed; z-index: 120; min-width: 190px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); display: grid; }
.pop-menu button { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 6px; background: none; text-align: left; cursor: pointer; }
.pop-menu button:hover, .pop-menu button:focus-visible { background: var(--brand-soft); outline: none; }
.pop-menu button.danger { color: var(--danger); }
.pop-menu .ico { width: 16px; height: 16px; }

/* ventanas modales */
.modal-back { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 16px; background: rgba(16, 23, 55, .4); }
.modal { width: min(440px, 100%); padding: 24px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.modal-title { margin: 0; font-size: 19px; }
.modal-text { margin: 0; color: var(--muted); }
.cf-field select, .modal select { padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }

/* búsqueda avanzada */
.adv-toggle { width: 30px; height: 30px; margin-right: -6px; }
.adv-toggle.on { color: var(--brand); background: var(--brand-soft); }
.adv-panel { margin: 0 14px 8px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); display: grid; gap: 12px; }
.adv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.adv-grid > * { min-width: 0; }
.adv-grid .cf-field input { width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.adv-checks { display: flex; flex-wrap: wrap; gap: 14px; }
.adv-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.adv-check input, .switch-row input { accent-color: var(--brand); }
.adv-panel .cf-buttons { margin-top: 0; }
.filter-chip { display: flex; align-items: center; gap: 8px; margin: 0 14px 6px; padding: 6px 6px 6px 10px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-size: 12.5px; }
.filter-chip span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-chip .ico { width: 14px; height: 14px; }

/* conversaciones */
.msg-count { flex: none; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 18px; text-align: center; }
.thread-count { margin: -8px 0 16px; }
.thread { display: grid; gap: 10px; }
.t-card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.t-card.open { box-shadow: var(--shadow-sm); }
.t-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; background: var(--panel); text-align: left; cursor: pointer; }
.t-head:hover { background: var(--panel-2); }
.t-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.t-snippet { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-card.open .t-snippet { display: none; }
.t-body { display: none; padding: 0 16px 16px; }
.t-card.open .t-body { display: block; }
.t-meta { display: flex; align-items: flex-start; gap: 10px; }
.t-actions { display: flex; gap: 2px; }
.t-body .mail-body { margin-top: 14px; }

/* vista previa de adjuntos */
.viewer { position: fixed; inset: 0; z-index: 115; display: flex; flex-direction: column; background: rgba(10, 12, 24, .92); }
.viewer-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; color: #fff; }
.viewer-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.viewer-head .icon-btn { color: rgba(255, 255, 255, .8); }
.viewer-head .icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .12); color: #fff; }
.viewer-head .btn.light { text-decoration: none; }
.viewer-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 16px 16px; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; background: #fff; }
.viewer-stage iframe { width: min(1000px, 100%); height: 100%; border: 0; border-radius: 4px; background: #fff; }
.viewer-text { width: min(1000px, 100%); max-height: 100%; overflow: auto; margin: 0; padding: 18px; border-radius: 6px; background: #fff; color: #161a2e; white-space: pre-wrap; font: 13px/1.5 ui-monospace, Consolas, monospace; }
.viewer .reader-empty { color: rgba(255, 255, 255, .8); }

/* avisos con acción (deshacer envío) */
.toast.action { display: flex; align-items: center; gap: 14px; }
.toast-btn { border: 0; background: none; color: var(--sky); font-weight: 700; cursor: pointer; padding: 2px 4px; }
.toast-btn:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- ajustes */
.settings-card { display: none; }
.view-settings .list-card, .view-settings .reader, .view-settings .contacts-card, .view-settings .contact-pane { display: none !important; }
.view-settings .settings-card { display: grid; grid-template-columns: 220px minmax(0, 1fr); grid-column: 2 / -1; min-height: 0; overflow: hidden; }
.view-contacts .settings-card { display: none; }
.view-settings .folders .folder.active { background: transparent; color: var(--text); font-weight: 400; box-shadow: none; }
.view-settings .folders .folder.active .ico { color: var(--muted); }
.settings-tabs { display: flex; flex-direction: column; gap: 2px; padding: 16px 10px; border-right: 1px solid var(--line); }
.stab { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-radius: 6px; background: none; text-align: left; cursor: pointer; color: var(--text); }
.stab:hover { background: var(--panel-2); }
.stab.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.settings-panel { overflow-y: auto; padding: 8px 32px 32px; }
.set-form { display: grid; gap: 6px; max-width: 680px; }
.set-section { padding: 20px 0; border-bottom: 1px solid var(--line); display: grid; gap: 12px; max-width: 680px; }
.set-section:last-of-type { border-bottom: 0; }
.set-title { margin: 0; font-size: 17px; }
.set-desc { margin: -6px 0 2px; font-size: 13.5px; }
.cf-field.narrow { max-width: 340px; }
.set-section > .btn, .set-section > select { justify-self: start; }
.switch-row { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch-row input { width: 18px; height: 18px; }
.sig-box { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.sig-box .c-tools { border-bottom: 1px solid var(--line); }
.sig-editor { min-height: 140px; max-height: 320px; }
.vac-fields { display: grid; gap: 12px; transition: opacity .15s; }
.vac-fields.disabled { opacity: .5; }
.vac-fields textarea { min-height: 120px; }
.filter-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.filter-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; }
.filter-item.off .filter-text { opacity: .55; }
.filter-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.rule-title { margin: 8px 0 0; font-size: 14px; font-weight: 600; font-family: var(--font); }
.rule-rows { display: grid; gap: 8px; }
.rule-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rule-row select, .rule-row input, .set-section > select { padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.rule-row input { flex: 1; min-width: 160px; }
.access-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.access-table th { text-align: left; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.access-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.access-table tr.failed td { color: var(--danger); }
.tag { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 11px; font-weight: 600; }
button.user-chip { cursor: pointer; font: inherit; color: var(--text); }
button.user-chip:hover { border-color: var(--brand); }

/* ---------------------------------------------------------------- avisos */
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { padding: 11px 18px; border-radius: 8px; background: var(--navy); color: #fff; box-shadow: var(--shadow); max-width: min(520px, 90vw); transition: opacity .4s, transform .4s; pointer-events: auto; font-size: 13.5px; }
.toast.error { background: #b4232f; }
.toast.ok { background: #0b7a54; }
.toast.out { opacity: 0; transform: translateY(8px); }

.backdrop, .fab { display: none !important; }

/* ---------------------------------------------------------------- pantallas medianas: carpetas en panel deslizable */
@media (max-width: 1399px) {
  .drawer-btn { display: inline-flex !important; }
  .workspace { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); }
  .side-col {
    position: fixed; top: 0; bottom: 0; left: var(--rail); width: 290px; z-index: 40; padding: 20px 16px;
    background: var(--bg); box-shadow: var(--shadow); transform: translateX(calc(-100% - var(--rail))); transition: transform .2s;
  }
  .show-sidebar .side-col { transform: none; }
  .show-sidebar .backdrop { display: block !important; position: fixed; inset: 0; z-index: 35; background: rgba(16, 23, 55, .35); }
}
@media (max-width: 1100px) {
  .topbar { padding: 18px 20px 14px; }
  .workspace { gap: 14px; padding: 0 20px 20px; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
  .user-mail { max-width: 160px; }
}

/* ---------------------------------------------------------------- móvil */
@media (max-width: 860px) {
  :root { --rail: 0px; }
  .rail { display: none; }
  .topbar { padding: 12px 14px; gap: 8px; }
  .page-title { font-size: 22px; }
  .crumbs { display: none; }
  .user-chip { padding: 0; border: 0; background: none; }
  .user-mail { display: none; }
  .workspace { grid-template-columns: 1fr; padding: 0; gap: 0; }
  .list-card { border-radius: 0; border-left: 0; border-right: 0; }
  .side-col { left: 0; width: 290px; }
  .reader { position: fixed; inset: 0; z-index: 20; border-radius: 0; border: 0; transform: translateX(100%); transition: transform .2s; }
  .show-reader .reader { transform: none; }
  .reader-inner { padding: 0 14px 24px; }
  .mail-body { padding-top: 14px; }
  .compose { inset: 0; width: auto; max-height: none; border-radius: 0; }
  .c-head { border-radius: 0; }
  .c-btn-label { display: none; }
  .fab { display: inline-flex !important; position: fixed; right: 18px; bottom: 18px; z-index: 15; width: 56px; height: 56px; border-radius: 16px; background: var(--brand); color: #fff; box-shadow: var(--shadow); }
  .fab:hover:not(:disabled) { background: var(--brand-hover); color: #fff; }
  .show-reader .fab, .composing .fab { display: none !important; }
  select.move { max-width: 92px; }
}
.only-mobile { display: none !important; }
@media (max-width: 860px) {
  .only-mobile { display: inline-flex !important; }
  .contacts-card { border-radius: 0; border-left: 0; border-right: 0; }
  .view-contacts .contact-pane { position: fixed; inset: 0; z-index: 20; border-radius: 0; border: 0; transform: translateX(100%); transition: transform .2s; }
  .show-detail .contact-pane { transform: none; }
  .contact-detail, .contact-form { padding: 0 16px 24px; }
  .cc-new { display: none; }
  .ac-list { left: 0; }
  .view-contacts .fab, .view-settings .fab { display: none !important; }
  .view-settings .settings-card { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); grid-column: 1; border-radius: 0; border-left: 0; border-right: 0; }
  .settings-tabs { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .stab { white-space: nowrap; }
  .settings-panel { padding: 4px 16px 24px; }
  .adv-grid { grid-template-columns: 1fr; }
  .folder-more { opacity: 1; }
  .access-table th:nth-child(3), .access-table td:nth-child(3) { display: none; }
}
@media (max-width: 1399px) and (min-width: 861px) {
  .view-settings .settings-card { grid-column: 1 / -1; }
}
