:root {
  --bg: #f6f7f9;
  --surface: #fff;
  --surface-soft: #fafbfc;
  --text: #18202f;
  --muted: #697386;
  --muted-2: #98a1b2;
  --line: #e7e9ee;
  --line-strong: #d9dde5;
  --accent: #d9692b;
  --accent-soft: #fff7f2;
  --success: #358060;
  --warning: #a66a25;
  --danger: #b54747;
  --sidebar-width: 232px;
  --radius: 11px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .025), 0 8px 24px rgba(15, 23, 42, .035);
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; }
body { min-height: 100%; margin: 0; color: var(--text); background: var(--bg); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased; }
body.mobile-menu-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
svg { display: block; }
code { padding: 2px 5px; color: #475569; background: #f1f3f6; border-radius: 5px; font-size: .92em; }

/* Estructura global */
.shell { display: flex; min-height: 100vh; }
.side { position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; width: var(--sidebar-width); flex-direction: column; padding: 22px 16px 18px; background: var(--surface); border-right: 1px solid var(--line); }
.main { width: calc(100% - var(--sidebar-width)); min-width: 0; margin-left: var(--sidebar-width); padding: 29px 32px 42px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 25px; }
.logo { display: block; width: 32px; height: 32px; flex: 0 0 32px; border-radius: 7px; object-fit: cover; }
.brand b { display: block; color: var(--text); font-size: 14px; font-weight: 720; letter-spacing: -.01em; }
.brand small { display: block; margin-top: 2px; color: var(--muted-2); font-size: 9px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }

.compose { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 40px; margin-bottom: 22px; padding: 0 13px; color: #fff; background: #202938; border-radius: 9px; box-shadow: 0 4px 12px rgba(32, 41, 56, .12); font-size: 13px; font-weight: 650; }
.compose:hover { background: #2a3444; }
.compose .nav-ico { width: 16px; height: 16px; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-section { display: block; margin: 1px 0 7px; padding: 0 10px; color: var(--muted-2); font-size: 10px; font-weight: 750; letter-spacing: .075em; line-height: 1; text-transform: uppercase; }
.nav-section-management { margin-top: 20px; }
.nav a { position: relative; display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px; color: #596274; border-radius: 8px; font-size: 13px; font-weight: 520; transition: color .15s ease, background .15s ease; }
.nav a:hover { color: var(--text); background: #f6f7f9; }
.nav a.active { color: var(--text); background: #f1f3f6; font-weight: 650; }
.nav a.active::before { position: absolute; left: 0; width: 2px; height: 16px; background: var(--accent); border-radius: 2px; content: ""; }
.nav-ico { display: grid; flex: 0 0 18px; width: 18px; height: 18px; place-items: center; }
.nav-ico svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav a .nav-ico { color: #8992a3; }
.nav a.active .nav-ico { color: #303a4b; }
.nav-count { display: inline-flex; min-width: 23px; min-height: 20px; align-items: center; justify-content: center; margin-left: auto; padding: 2px 7px; color: #596274; background: #e8ebf0; border-radius: 999px; font-size: 10px; font-weight: 720; line-height: 1; }
.nav a.active .nav-count { color: #30394a; background: #dde1e7; }
.spacer { flex: 1; }

.side-footer { padding: 15px 8px 0; border-top: 1px solid var(--line); }
.mode { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; color: var(--muted-2); font-size: 9px; font-weight: 750; letter-spacing: .07em; }
.mode i { width: 5px; height: 5px; background: var(--success); border-radius: 50%; }
.side-user { display: flex; align-items: center; gap: 9px; min-width: 0; }
.user-avatar { display: grid; width: 32px; height: 32px; flex: 0 0 32px; place-items: center; color: #596274; background: #edf0f4; border-radius: 50%; font-size: 11px; font-weight: 750; }
.side-user > div { min-width: 0; }
.side-user b { display: block; overflow: hidden; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.logout { display: block; margin-top: 2px; color: var(--muted-2); font-size: 10px; }
.logout:hover { color: var(--danger); }

/* Títulos y controles */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 23px; }
.top h1 { margin: 0; color: var(--text); font-size: 25px; font-weight: 710; letter-spacing: -.035em; line-height: 1.2; }
.top h1 + .muted { margin-top: 7px; }
.topgap { margin-top: 18px; }
.muted { color: var(--muted); font-size: 12px; }
.small { font-size: 10px; }

.search { display: grid; width: min(660px, 58%); grid-template-columns: minmax(190px, 1.35fr) minmax(150px, .8fr) auto; gap: 8px; }
.search input[type="hidden"] { display: none; }

.field { margin: 0 0 14px; }
.field label { display: block; margin-bottom: 6px; color: #566174; font-size: 11px; font-weight: 680; letter-spacing: .01em; }
.field input, .field select, .field textarea, .search input, .search select { width: 100%; min-height: 40px; padding: 9px 11px; color: var(--text); background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; outline: none; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
.field textarea { min-height: 124px; line-height: 1.5; resize: vertical; }
.field textarea.big { min-height: 270px; }
.field textarea.smallbox { min-height: 88px; }
.field input[type="file"] { padding: 8px; background: var(--surface-soft); }
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus, .search select:focus { border-color: #b9c0cb; box-shadow: 0 0 0 3px rgba(100, 116, 139, .07); }
.field input::placeholder, .field textarea::placeholder, .search input::placeholder { color: #a3aab7; }

.btn { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; gap: 7px; padding: 8px 13px; background: transparent; border: 1px solid transparent; border-radius: 8px; font-size: 12px; font-weight: 650; line-height: 1.2; cursor: pointer; transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease; }
.btn.primary { color: #fff; background: #202938; border-color: #202938; box-shadow: 0 3px 8px rgba(32, 41, 56, .1); }
.btn.primary:hover { background: #2b3545; }
.btn.secondary { color: #566174; background: #fff; border-color: var(--line-strong); }
.btn.secondary:hover { color: var(--text); background: #f8f9fb; }
.btn.danger, .permanent-delete-btn { color: var(--danger); background: #fff; border-color: #ead4d4; }
.btn.danger:hover:not(:disabled), .permanent-delete-btn:hover { background: #fcf7f7; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.full { width: 100%; }

/* Resumen, paneles y tablas */
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.card, .panel, .message, .box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card { min-width: 0; padding: 16px 17px; }
.dashboard-card { display: block; outline: none; cursor: pointer; transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.dashboard-card:hover { border-color: #d3d8e0; box-shadow: 0 12px 28px rgba(15, 23, 42, .09); transform: translateY(-2px); }
.dashboard-card:focus-visible { border-color: #aeb6c3; box-shadow: 0 0 0 3px rgba(100, 116, 139, .12), 0 10px 24px rgba(15, 23, 42, .07); }
.dashboard-card:active { transform: translateY(0); }
.num { color: var(--text); font-size: 21px; font-weight: 710; letter-spacing: -.025em; }
.num + .muted { margin-top: 6px; }
.panel { overflow: hidden; box-shadow: var(--shadow); }
.ph { display: flex; min-height: 51px; align-items: center; justify-content: space-between; gap: 16px; padding: 0 16px; background: #fff; border-bottom: 1px solid var(--line); }
.ph b { font-size: 13px; font-weight: 680; }
.tablewrap { overflow-x: auto; }
table { width: 100%; min-width: 850px; border-collapse: collapse; }
th, td { padding: 13px 14px; text-align: left; vertical-align: middle; }
th { color: var(--muted-2); background: #fcfcfd; border-bottom: 1px solid var(--line); font-size: 10px; font-weight: 700; letter-spacing: .055em; text-transform: uppercase; }
td { border-bottom: 1px solid #eff1f4; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; transition: background .15s ease; }
tbody tr.click:hover, tbody tr.click:hover td { background: #fafbfc; }
tbody tr.click.unread, tbody tr.click.unread td { background: #f5f6f8; }
tbody tr.click.unread:hover, tbody tr.click.unread:hover td { background: #f0f2f5; }
.sender, .subject { color: #30394a; font-weight: 630; }
.unread .sender, .unread .subject { color: #111827; font-weight: 730; }
.preview { max-width: 430px; margin-top: 4px; overflow: hidden; color: var(--muted-2); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.pill, .badge { display: inline-flex; min-height: 25px; align-items: center; justify-content: center; gap: 6px; padding: 5px 9px; color: #5f6879; background: #f7f8fa; border: 1px solid #e8ebef; border-radius: 999px; font-size: 10px; font-weight: 650; line-height: 1; text-align: center; vertical-align: middle; }
.pill { max-width: 190px; overflow: hidden; border-radius: 6px; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.badge::before { width: 5px; height: 5px; flex: 0 0 5px; background: #98a1b2; border-radius: 50%; content: ""; }
.badge.pending::before { background: var(--warning); }
.badge.replied::before { background: var(--success); }
.badge.high::before, .badge.failed::before { background: var(--danger); }
.badge.label::before, .badge.file::before, .badge.delivery::before { display: none; }
.badge.label { color: #586174; background: #f2f4f7; }
.badge.file { border-style: dashed; }
.badge.tall, .pill.tall { min-height: 28px; padding: 6px 9px; }
.labels, .rightmeta, .actionsline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mt6 { margin-top: 7px; }
.empty { padding: 48px 20px; color: var(--muted); text-align: center; }

.bulk-trash-bar { display: flex; justify-content: flex-end; padding: 10px 14px; background: #fcfcfd; border-bottom: 1px solid var(--line); }
.bulk-trash-bar form { display: flex; gap: 8px; flex-wrap: wrap; }
.thread-check, .thread-select-all { width: 15px; height: 15px; margin: 0 8px 0 0; accent-color: #344054; vertical-align: middle; }

@media (min-width: 701px) {
  .tablewrap td:has(> .thread-check) { position: relative; padding-left: 43px; }
  .tablewrap td > .thread-check { position: absolute; top: 50%; left: 14px; margin: 0; transform: translateY(-50%); }
}

/* Redacción y contactos */
.formpanel { max-width: 920px; padding: 22px; }
.formpanel form > .btn:last-child { min-width: 140px; }
.email-html-frame { display: block; width: 100%; min-height: 350px; border: 0; background: #fff; }
.contact { display: flex; min-height: 67px; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 16px; border-bottom: 1px solid #eff1f4; }
.contact:last-child { border-bottom: 0; }
.contact b { color: #30394a; font-size: 13px; font-weight: 650; }

/* Conversación */
.thread { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 360px); gap: 16px; align-items: start; }
.thread-messages { min-width: 0; }
.thread > .sidebar { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 12px; }
.message { overflow: hidden; margin-bottom: 12px; }
.message.inbound.unread .meta { background: #f5f6f8; }
.meta { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 16px; background: #fcfcfd; border-bottom: 1px solid var(--line); }
.meta b { color: #30394a; font-size: 12px; font-weight: 680; }
.body { padding: 19px; overflow-wrap: anywhere; line-height: 1.6; white-space: pre-wrap; }
.msgfoot { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 18px; background: #fcfcfd; border-top: 1px solid #eff1f4; }
.mini { color: #536175; font-size: 10px; font-weight: 650; text-decoration: underline; text-decoration-color: #c8cdd5; text-underline-offset: 3px; }
.attachments { padding: 0 18px 18px; }
.attachments > b { color: #566174; font-size: 11px; }
.attlist { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 8px; }
.att { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; color: #566174; background: #f8f9fb; border: 1px solid var(--line); border-radius: 7px; font-size: 11px; }
.box { padding: 17px; }
.box > b { color: #30394a; font-size: 13px; font-weight: 680; }
.noborder { border: 0; box-shadow: none; }
.inlineform { margin-top: 13px; }
.note { margin: 9px 0; padding: 10px 11px; color: #4e596a; background: #f8f9fb; border-left: 2px solid #b9c0cb; border-radius: 6px; font-size: 11px; line-height: 1.5; }
.thread-top-actions { justify-content: flex-end; }
.thread-trash-top-form { display: inline-flex; margin: 0; }
.thread-trash-icon { display: grid; width: 15px; height: 15px; place-items: center; }
.thread-trash-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.star-indicator { color: #7d8797; font-size: 11px; }
.delivery.simulated { color: #66607d; }
.delivery.sent { color: var(--success); }
.delivery.sending { color: var(--warning); }
.delivery.failed, .deliveryerror { color: var(--danger); }
.delivery.stored { color: #697386; }

/* Alertas y diagnóstico */
.flash { padding: 11px 13px; margin-bottom: 16px; border: 1px solid; border-radius: 8px; font-size: 12px; }
.flash.success { color: #2f6f53; background: #f4faf7; border-color: #dceee5; }
.flash.error { color: #9b4141; background: #fcf7f7; border-color: #efdada; }
.hint { margin: 13px 0; padding: 10px 11px; color: #6a5d4b; background: #fbfaf8; border: 1px solid #ece7df; border-radius: 8px; font-size: 11px; }
.diaggrid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; padding: 16px; }
.diagitem { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; padding: 11px; background: #fcfcfd; border: 1px solid var(--line); border-radius: 8px; font-size: 11px; font-weight: 620; }

/* Configuración de cuentas */
.settings-accounts { overflow: visible; background: #f8f9fb; border-color: var(--line); box-shadow: var(--shadow); }
.account-section-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 23px; background: #fff; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.account-section-header h2 { margin: 3px 0 5px; color: var(--text); font-size: 20px; font-weight: 700; letter-spacing: -.025em; }
.account-section-header p { margin: 0; color: var(--muted); font-size: 12px; }
.account-eyebrow { color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.account-total { flex: 0 0 auto; padding: 7px 10px; color: #386f58; background: #f4faf7; border: 1px solid #dceee5; border-radius: 999px; font-size: 10px; font-weight: 700; }
.account-total span { color: var(--muted); font-weight: 550; }
.account-create { margin: 18px; padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.account-create-heading, .account-identity { display: flex; align-items: center; gap: 11px; }
.account-create-heading b, .account-identity b { display: block; color: #30394a; font-size: 13px; font-weight: 680; }
.account-create-heading span:not(.account-icon), .account-identity span:not(.account-icon) { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.account-icon { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; color: #596274; background: #f1f3f6; border: 1px solid var(--line); border-radius: 9px; font-size: 12px; font-weight: 750; }
.account-icon-new { color: var(--muted); font-size: 18px; font-weight: 450; }
.account-form { margin-top: 17px; }
.account-editor { margin: 11px 18px 0; padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 10px; transition: border-color .16s ease, box-shadow .16s ease; }
.account-editor:hover { border-color: var(--line-strong); box-shadow: 0 4px 14px rgba(15, 23, 42, .035); }
.account-editor:last-child { margin-bottom: 18px; }
.account-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.account-identity, .account-identity > div { min-width: 0; }
.account-identity b, .account-identity span:not(.account-icon) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-state { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 6px; padding: 6px 9px; color: var(--muted); background: #f4f5f7; border-radius: 999px; font-size: 10px; font-weight: 680; }
.account-state i { width: 5px; height: 5px; background: currentColor; border-radius: 50%; }
.account-state.is-active { color: var(--success); background: #f4faf7; }
.account-fields { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 11px; }
.account-fields .field { margin-bottom: 0; }
.account-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 17px; padding-top: 15px; border-top: 1px solid #eff1f4; }
.account-active { display: inline-flex; align-items: center; gap: 7px; padding: 7px 9px; color: #4f5a6b; background: #f8f9fb; border: 1px solid var(--line); border-radius: 7px; font-size: 11px; font-weight: 650; cursor: pointer; }
.account-active input { width: 15px; height: 15px; margin: 0; accent-color: #344054; }
.account-message-count { white-space: nowrap; }
.account-action-spacer { flex: 1; }
.account-create-form .account-actions { justify-content: space-between; }

/* Login */
.loginbg { display: grid; min-height: 100vh; place-items: center; padding: 22px; background: #f2f4f7; }
.login { width: min(410px, 100%); padding: 28px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 50px rgba(15, 23, 42, .08); }
.loginbrand { padding: 0 0 20px; }
.login h1 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.login h1 + .muted { margin: 7px 0 20px; }
.passkey-btn { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 9px; color: #fff; background: #202938; border-color: #202938; }
.passkey-btn:hover { color: #fff; background: #111827; border-color: #111827; }
.passkey-btn[hidden] { display: none !important; }
.passkey-btn[aria-busy="true"] { cursor: wait; opacity: .7; }
.passkey-icon { display: grid; width: 20px; height: 20px; flex: 0 0 20px; place-items: center; }
.passkey-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; }
.login-divider { display: none; align-items: center; gap: 10px; margin: 18px 0; color: var(--muted-2); font-size: 10px; }
.login-divider.is-visible { display: flex; }
.login-divider::before, .login-divider::after { height: 1px; flex: 1; background: var(--line); content: ""; }
.login-divider span { white-space: nowrap; }
.passkey-status { min-height: 17px; margin: 11px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.passkey-status:empty { min-height: 0; margin-top: 0; }
.passkey-status.is-error { color: var(--danger); }

/* Biometría / passkeys */
.passkey-settings { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px 28px; align-items: center; margin-bottom: 18px; padding: 22px; }
.passkey-settings-copy h2 { margin: 4px 0 6px; color: var(--text); font-size: 20px; letter-spacing: -.025em; }
.passkey-settings-copy p { max-width: 690px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.passkey-settings-copy .passkey-note { margin-top: 7px; color: var(--muted-2); font-size: 10px; }
.passkey-settings-action { min-width: 225px; text-align: right; }
.passkey-settings-action .passkey-status { max-width: 300px; text-align: right; }
.passkey-list { grid-column: 1 / -1; border-top: 1px solid var(--line); }
.passkey-device { display: grid; min-height: 61px; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 12px 0; border-bottom: 1px solid #eff1f4; }
.passkey-device:last-child { padding-bottom: 0; border-bottom: 0; }
.passkey-device-icon { display: grid; width: 30px; height: 30px; place-items: center; color: var(--success); background: #f4faf7; border: 1px solid #dceee5; border-radius: 50%; font-size: 12px; font-weight: 750; }
.passkey-device b, .passkey-device span { display: block; }
.passkey-device b { color: #30394a; font-size: 12px; }
.passkey-device div > span { margin-top: 3px; color: var(--muted-2); font-size: 10px; }
.passkey-device form { margin: 0; }

/* Menú móvil, oculto en escritorio */
.mobile-more-btn, .mobile-more-overlay, .mobile-more-sheet { display: none; }

@media (max-width: 1180px) {
  :root { --sidebar-width: 212px; }
  .main { padding: 25px 23px 38px; }
  .diaggrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .thread { grid-template-columns: minmax(0, 1fr) 300px; }
}

@media (max-width: 960px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .thread { grid-template-columns: 1fr; }
  .thread > .sidebar { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .thread > .sidebar .box:first-child { grid-column: 1 / -1; }
  .top { align-items: stretch; flex-direction: column; gap: 14px; }
  .search { width: 100%; }
}

@media (max-width: 700px) {
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .shell { display: block; }
  .side { position: relative; inset: auto; display: grid; width: 100%; grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: 12px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { min-width: 0; padding: 0; }
  .brand small { display: none; }
  .compose { width: auto; min-height: 38px; margin: 0; padding: 0 13px; box-shadow: none; }
  .spacer, .side-footer { display: none; }
  .main { width: 100%; margin-left: 0; padding: 20px 13px 28px; }

  .side .nav { position: fixed; inset: auto 0 0; z-index: 1000; display: grid; height: calc(65px + env(safe-area-inset-bottom)); grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; padding: 6px 6px calc(5px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .97); border-top: 1px solid var(--line-strong); box-shadow: 0 -5px 18px rgba(15, 23, 42, .055); backdrop-filter: blur(14px); }
  .side .nav > a, .mobile-more-btn { display: flex; min-width: 0; min-height: 51px; align-items: center; justify-content: center; flex-direction: column; gap: 3px; padding: 4px 2px; color: #7c8697; background: transparent; border: 0; border-radius: 8px; font-size: 9px; font-weight: 620; cursor: pointer; }
  .side .nav > a::before { display: none; }
  .side .nav > a .nav-ico, .mobile-more-btn .nav-ico { width: 20px; height: 20px; color: currentColor; }
  .side .nav > a.active, .mobile-more-btn.active, .mobile-more-btn.opened { color: #202938; background: #f1f3f6; }
  .side .nav > a.active::after, .mobile-more-btn.active::after, .mobile-more-btn.opened::after { position: absolute; top: 2px; width: 18px; height: 2px; background: var(--accent); border-radius: 2px; content: ""; }
  .side .nav > a, .mobile-more-btn { position: relative; }
  .side .nav > a[data-page="all"], .side .nav > a[data-page="spam"], .side .nav > a[data-page="trash"], .side .nav > a[data-page="contacts"], .side .nav > a[data-page="settings"] { display: none; }
  .side .nav > .nav-section { display: none; }
  .side .nav .nav-count { position: absolute; top: 3px; left: calc(50% + 5px); min-width: 16px; min-height: 16px; margin: 0; padding: 2px 4px; color: #596274; background: #e8ebf0; border: 2px solid #fff; font-size: 8px; }
  .mobile-more-btn { display: flex; }

  .mobile-more-overlay { position: fixed; inset: 0; z-index: 1990; display: block; background: rgba(24, 32, 47, .28); opacity: 0; visibility: hidden; backdrop-filter: blur(2px); transition: opacity .18s ease, visibility .18s ease; }
  .mobile-more-overlay.open { opacity: 1; visibility: visible; }
  .mobile-more-sheet { position: fixed; right: 10px; bottom: calc(72px + env(safe-area-inset-bottom)); left: 10px; z-index: 2000; display: block; max-height: calc(100vh - 105px); padding: 10px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 45px rgba(15, 23, 42, .16); opacity: 0; visibility: hidden; transform: translateY(16px); transition: opacity .18s ease, transform .18s ease, visibility .18s ease; }
  .mobile-more-sheet.open { opacity: 1; visibility: visible; transform: translateY(0); }
  .mobile-more-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 8px 11px; border-bottom: 1px solid var(--line); }
  .mobile-more-header b, .mobile-more-header span { display: block; }
  .mobile-more-header b { font-size: 13px; }
  .mobile-more-header span { margin-top: 2px; color: var(--muted-2); font-size: 10px; }
  .mobile-more-close { display: grid; width: 32px; height: 32px; place-items: center; color: var(--muted); background: #f5f6f8; border: 0; border-radius: 8px; font-size: 21px; cursor: pointer; }
  .mobile-sheet-link { display: grid; min-height: 49px; grid-template-columns: 22px 1fr; align-items: center; gap: 11px; margin-top: 3px; padding: 9px 10px; color: #4f5a6b; border-radius: 8px; font-size: 13px; font-weight: 620; }
  .mobile-sheet-link .nav-ico { width: 18px; height: 18px; color: #7d8797; }
  .mobile-sheet-link.active { color: var(--text); background: #f1f3f6; }
  .mobile-sheet-logout { margin-top: 7px; color: var(--danger); border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; }

  .top { gap: 13px; margin-bottom: 18px; }
  .top h1 { font-size: 22px; }
  .search { grid-template-columns: 1fr; }
  .cards { gap: 8px; margin-bottom: 12px; }
  .card { padding: 13px; }
  .num { font-size: 19px; }
  .panel { overflow: visible; box-shadow: none; }
  .ph { min-height: 48px; padding: 0 13px; }
  .bulk-trash-bar { justify-content: stretch; padding: 10px; }
  .bulk-trash-bar form, .bulk-trash-btn { width: 100%; }

  .tablewrap { overflow: visible; }
  table, tbody { display: block; width: 100%; min-width: 0; }
  thead { display: none; }
  tbody { padding: 9px; }
  tbody tr, tbody tr.click { position: relative; display: block; margin-bottom: 9px; padding: 14px 13px 13px 44px; background: #fff; border: 1px solid var(--line); border-radius: 9px; }
  tbody tr:last-child { margin-bottom: 0; }
  tbody tr.click.unread, tbody tr.click.unread td, tbody tr.click.unread:hover, tbody tr.click.unread:hover td { background: #f3f4f6; }
  td { display: block; padding: 0; background: transparent !important; border: 0; }
  td:first-child { min-height: 34px; padding-right: 72px; }
  td:nth-child(2) { margin-top: 10px; }
  td:nth-child(3), td:nth-child(4) { display: inline-block; max-width: 100%; margin: 10px 5px 0 0; }
  td:nth-child(5) { position: absolute; top: 15px; right: 13px; color: var(--muted-2); font-size: 10px; }
  .thread-check { position: absolute; top: 16px; left: 14px; margin: 0; }
  .sender, .subject, .preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .preview { max-width: 100%; }
  .pill { max-width: min(190px, 62vw); }

  .formpanel { width: 100%; padding: 16px; }
  .formpanel form > .btn:last-child { width: 100%; }
  .contact { padding: 12px 13px; }
  .thread > .sidebar { display: flex; }
  .thread-top-actions { width: 100%; justify-content: flex-start; }
  .thread-trash-text { display: none; }
  .thread-trash-top-btn { width: 37px; min-width: 37px; padding: 0; }
  .meta { align-items: flex-start; flex-direction: column; }
  .rightmeta { width: 100%; justify-content: flex-start; }
  .body { padding: 16px; }
  .msgfoot { align-items: flex-start; flex-direction: column; padding: 11px 15px; }
  .email-html-frame { min-height: 300px; }

  .diaggrid { grid-template-columns: 1fr; padding: 12px; }
  .account-section-header { align-items: flex-start; flex-direction: column; gap: 13px; padding: 18px; }
  .account-total { align-self: flex-start; }
  .account-create, .account-editor { margin-right: 11px; margin-left: 11px; padding: 15px; }
  .account-create { margin-top: 11px; margin-bottom: 11px; }
  .account-editor { margin-top: 9px; }
  .account-editor:last-child { margin-bottom: 11px; }
  .account-editor-head { align-items: flex-start; }
  .account-fields { grid-template-columns: 1fr; }
  .account-active, .account-message-count { width: 100%; }
  .account-action-spacer { display: none; }
  .account-actions .btn { flex: 1 1 calc(50% - 5px); }
  .account-create-form .account-actions .btn { flex-basis: 100%; }
  .passkey-settings { grid-template-columns: 1fr; gap: 16px; padding: 18px; }
  .passkey-settings-action { min-width: 0; text-align: left; }
  .passkey-settings-action .passkey-btn { width: 100%; }
  .passkey-settings-action .passkey-status { max-width: none; text-align: left; }
  .passkey-device { grid-template-columns: 32px minmax(0, 1fr); }
  .passkey-device form { grid-column: 1 / -1; }
  .passkey-device form .btn { width: 100%; }
}

@media (max-width: 420px) {
  .main { padding-right: 10px; padding-left: 10px; }
  .compose span:last-child { display: none; }
  .compose { width: 38px; padding: 0; }
  .cards { grid-template-columns: 1fr; }
  .account-state { padding: 5px 7px; }
  .account-actions .btn { flex-basis: 100%; }
  .contact .badge { flex: 0 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Drag & drop de conversaciones - escritorio */
.thread-drag-handle {
  display: inline-flex;
  width: 18px;
  height: 28px;
  align-items: center;
  justify-content: center;
  margin-right: 5px;
  color: #a0a7b3;
  border-radius: 5px;
  cursor: grab;
  font-size: 16px;
  line-height: 1;
  vertical-align: middle;
  opacity: 0;
  transition: opacity .15s ease, background .15s ease, color .15s ease;
}

tr.click:hover .thread-drag-handle {
  opacity: 1;
}

.thread-drag-handle:hover {
  color: #475569;
  background: #eef0f3;
}

.thread-drag-handle:active {
  cursor: grabbing;
}

.thread-dragging {
  opacity: .48;
}

.thread-drop-dock {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 2500;
  display: flex;
  gap: 12px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 24px);
  transition: opacity .16s ease, transform .16s ease;
}

.thread-drop-dock.visible {
  pointer-events: auto;
  opacity: 1;
  transform: translate(-50%, 0);
}

.thread-drop-target {
  display: flex;
  min-width: 190px;
  height: 62px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  background: #fff;
  border: 2px dashed #cbd0d8;
  border-radius: 12px;
  box-shadow: 0 12px 35px rgba(15,23,42,.16);
  color: #566174;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}

.thread-drop-target span {
  font-size: 20px;
}

.thread-drop-target.over {
  transform: scale(1.04);
  border-style: solid;
  background: #f7f8fa;
}

.thread-drop-spam.over {
  border-color: #a66a25;
}

.thread-drop-trash.over {
  border-color: #b54747;
}

@media (max-width: 900px) {
  .thread-drag-handle,
  .thread-drop-dock {
    display: none !important;
  }
}
