.mail-page { max-width: 1500px; margin: 0 auto; color: var(--text-primary, #1e293b); }
.mail-page-header { margin-bottom: 1.5rem; padding: .4rem .2rem; }
.mail-page-header h1 { margin: .25rem 0; font-size: clamp(1.7rem, 3vw, 2.4rem); }
.mail-page-header p { margin: 0; color: #64748b; }
.mail-eyebrow { color: #6366f1; font-weight: 800; font-size: .72rem; letter-spacing: .16em; }
.mail-account-layout { display: grid; grid-template-columns: minmax(290px, .85fr) minmax(320px, 1.15fr); gap: 1.5rem; }
.mail-login-card, .mail-saved-accounts, .mail-content, .mail-topbar { background: var(--bg-card, #fff); border: 1px solid rgba(148,163,184,.2); box-shadow: 0 12px 35px rgba(15,23,42,.07); border-radius: 22px; }
.mail-login-card { padding: 2rem; }
.mail-login-icon { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; margin-bottom: 1rem; color: #fff; font-size: 1.35rem; background: linear-gradient(135deg,#6366f1,#8b5cf6); }
.mail-login-card h2, .mail-saved-accounts h2 { margin: 0 0 .35rem; }
.mail-login-card > p { margin: 0 0 1.25rem; color: #64748b; }
.mail-login-form { display: grid; gap: .9rem; }
.mail-field { display: grid; gap: .4rem; color: #475569; font-size: .82rem; font-weight: 700; }
.mail-input, .mail-account-select, .mail-search-input, .mail-compose-body { width: 100%; border: 1px solid #dbe3ef; background: var(--bg-card,#fff); color: var(--text-primary,#1e293b); border-radius: 12px; padding: .8rem .9rem; outline: none; box-sizing: border-box; font: inherit; }
.mail-input:focus, .mail-account-select:focus, .mail-search-input:focus, .mail-compose-body:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.mail-password-field { position: relative; }
.mail-password-field .mail-input { padding-right: 3.2rem; }
.mail-password-toggle { position: absolute; top: 50%; right: .7rem; width: 38px; height: 38px; display: grid; place-items: center; transform: translateY(-50%); border: 0; border-radius: 10px; background: transparent; color: #64748b; cursor: pointer; transition: color .2s ease, background-color .2s ease; }
.mail-password-toggle:hover, .mail-password-toggle:focus-visible { color: #4f46e5; background: #eef2ff; outline: none; }
.mail-submit { min-height: 46px; }
.mail-security-note { margin: .1rem 0 0; color: #64748b; font-size: .76rem; line-height: 1.5; }
.mail-saved-accounts { padding: 1.25rem; }
.mail-section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.mail-count-pill { min-width: 28px; height: 28px; display: grid; place-items: center; border-radius: 999px; color: #4f46e5; background: #eef2ff; font-weight: 800; }
.mail-account-card { border: 1px solid #e2e8f0; border-radius: 15px; margin-bottom: .75rem; overflow: hidden; background: rgba(248,250,252,.55); }
.mail-account-open { width: 100%; border: 0; background: transparent; display: grid; grid-template-columns: auto 1fr auto; gap: .9rem; align-items: center; padding: 1rem; text-align: left; cursor: pointer; color: inherit; }
.mail-account-open:hover { background: rgba(99,102,241,.05); }
.mail-account-avatar, .mail-sender-avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; flex: 0 0 auto; color: #4f46e5; background: #eef2ff; font-weight: 900; }
.mail-account-copy { min-width: 0; display: grid; gap: .15rem; }
.mail-account-copy strong { overflow: hidden; text-overflow: ellipsis; }
.mail-account-copy span { font-size: .75rem; }
.mail-status-ok { color: #059669; }
.mail-status-error { color: #dc2626; }
.mail-account-actions { display: flex; justify-content: flex-end; gap: 1rem; padding: .65rem 1rem; border-top: 1px solid #e2e8f0; }
.mail-link-button { border: 0; background: transparent; color: #4f46e5; font-size: .75rem; font-weight: 700; cursor: pointer; }
.mail-link-button.danger { color: #dc2626; }
.mail-empty-accounts, .mail-empty-list { min-height: 220px; display: grid; place-content: center; justify-items: center; text-align: center; color: #94a3b8; }
.mail-empty-accounts i, .mail-empty-list i { font-size: 2.5rem; margin-bottom: .75rem; }
.mail-shell-layout { display: grid; grid-template-rows: auto auto; align-content: start; gap: 1rem; min-height: calc(100vh - 130px); }
.mail-topbar { overflow: hidden; }
.mail-topbar-main { display: grid; grid-template-columns: auto minmax(300px,1fr) auto; align-items: center; gap: 1rem; padding: 1rem 1.15rem; }
.mail-back-accounts { min-height: 44px; border: 0; border-radius: 12px; padding: .7rem .9rem; background: transparent; color: #6366f1; font-weight: 800; cursor: pointer; white-space: nowrap; }
.mail-active-account { display: grid; grid-template-columns: auto minmax(220px,420px); align-items: center; gap: .75rem; min-width: 0; }
.mail-active-account > span { color: #64748b; font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.mail-account-select { min-height: 44px; }
.mail-compose-button { width: auto; min-height: 44px; margin: 0; padding-inline: 1.25rem; white-space: nowrap; }
.mail-folders { display: grid; grid-template-columns: repeat(4,minmax(120px,1fr)); gap: .35rem; padding: .55rem; border-top: 1px solid #e2e8f0; background: rgba(248,250,252,.72); }
.mail-folder-link { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: .5rem; border: 0; border-radius: 11px; padding: .75rem; background: transparent; color: #64748b; text-align: left; cursor: pointer; }
.mail-folder-link.active { color: #4f46e5; background: #eef2ff; font-weight: 800; }
.mail-folder-link strong { min-width: 25px; padding: .14rem .4rem; border-radius: 999px; text-align: center; color: #fff; background: #6366f1; font-size: .68rem; }
.mail-content { width: 100%; min-width: 0; overflow: hidden; }
.mail-list-toolbar { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid #e2e8f0; }
.mail-list-toolbar h2 { margin: 0; }
.mail-list-toolbar span { color: #94a3b8; font-size: .78rem; }
.mail-search { width: min(360px, 45%); min-height: 48px; display: flex; align-items: center; gap: .65rem; overflow: hidden; border: 1px solid #dbe3ef; border-radius: 12px; padding: 0 .9rem; background: var(--color-surface,#fff); }
.mail-search > i { flex: 0 0 auto; color: #64748b; }
.mail-search-input { min-width: 0; border: 0; border-radius: 0; padding: .7rem 0; background: transparent; box-shadow: none!important; }
.mail-message-list { min-height: 380px; }
.mail-message-row { width: 100%; min-height: 67px; display: grid; grid-template-columns: 42px minmax(130px,.7fr) minmax(180px,1.4fr) auto; gap: .9rem; align-items: center; border: 0; border-bottom: 1px solid #edf2f7; padding: .75rem 1.1rem; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.mail-message-row:hover { background: rgba(99,102,241,.045); }
.mail-message-row.unread { background: rgba(238,242,255,.65); }
.mail-message-row.unread .mail-message-sender, .mail-message-row.unread .mail-message-subject strong { font-weight: 900; color: #1e293b; }
.mail-message-sender, .mail-message-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-message-subject { display: flex; align-items: center; gap: .5rem; }
.mail-message-row time { color: #64748b; font-size: .75rem; white-space: nowrap; }
.mail-pagination { display: flex; justify-content: center; align-items: center; gap: 1rem; padding: 1rem; }
.mail-detail { min-height: 580px; }
.mail-detail-actions, .mail-compose-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid #e2e8f0; }
.mail-detail-actions > div { display: flex; gap: .5rem; }
.mail-icon-button { width: 38px; height: 38px; border: 1px solid #e2e8f0; border-radius: 11px; background: var(--bg-card,#fff); color: #475569; cursor: pointer; }
.mail-detail-header { padding: 1.5rem; border-bottom: 1px solid #edf2f7; }
.mail-detail-header h2 { margin: 0 0 1.25rem; font-size: 1.45rem; }
.mail-detail-meta { display: grid; grid-template-columns: 42px 1fr auto; gap: .8rem; align-items: center; }
.mail-detail-meta > div:nth-child(2) { display: grid; }
.mail-detail-meta span, .mail-detail-meta time { color: #64748b; font-size: .78rem; }
.mail-attachments { display: flex; flex-wrap: wrap; gap: .5rem; padding: 1rem 1.5rem; border-bottom: 1px solid #edf2f7; }
.mail-attachment { border: 1px solid #dbe3ef; border-radius: 10px; padding: .55rem .75rem; background: #f8fafc; color: #475569; cursor: pointer; }
.mail-html-frame { width: 100%; min-height: 480px; border: 0; padding: 1.5rem; box-sizing: border-box; background: #fff; }
.mail-text-body { margin: 0; padding: 1.5rem; white-space: pre-wrap; overflow-wrap: anywhere; font: 15px/1.65 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; color: #334155; }
.mail-compose { display: flex; flex-direction: column; min-height: min(680px, calc(100vh - 270px)); }
.mail-compose-header { justify-content: flex-start; }
.mail-compose-header h2 { margin: 0; }
.mail-compose-header span { color: #64748b; font-size: .78rem; }
.mail-compose-fields { display: grid; gap: .55rem; padding: 1rem 1.25rem; border-bottom: 1px solid #e2e8f0; }
.mail-compose-body { flex: 1; min-height: 280px; border: 0; border-radius: 0; resize: vertical; padding: 1.25rem; box-shadow: none!important; }
.mail-compose-footer { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-top: 1px solid #e2e8f0; }
.mail-file-label { color: #4f46e5; font-weight: 800; cursor: pointer; }
.mail-file-input { max-width: 210px; margin-left: .5rem; color: #64748b; font-size: .72rem; }
.mail-loading { min-height: 300px; display: flex; align-items: center; justify-content: center; gap: .8rem; color: #64748b; }
.mail-error-block, .mail-connection-error { min-height: 360px; display: grid; place-content: center; justify-items: center; text-align: center; padding: 2rem; }
.mail-error-block > i, .mail-connection-error > i { font-size: 2.8rem; color: #f59e0b; margin-bottom: 1rem; }
.mail-connection-error > div { display: flex; gap: .7rem; }
.mail-modal-overlay { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 1rem; background: rgba(15,23,42,.55); backdrop-filter: blur(5px); }
.mail-modal { width: min(440px,100%); border-radius: 20px; background: #fff; box-shadow: 0 24px 70px rgba(15,23,42,.28); }
.mail-modal-header, .mail-modal-footer { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; }
.mail-modal-header { border-bottom: 1px solid #e2e8f0; }
.mail-modal-header h3 { margin: 0; }
.mail-modal-body { display: grid; gap: .8rem; padding: 1.25rem; }
.mail-modal-footer { justify-content: flex-end; gap: .6rem; border-top: 1px solid #e2e8f0; }
/* Premium desktop refinements */
.mail-page { position: relative; isolation: isolate; }
.mail-account-page::before { content: ''; position: absolute; z-index: -1; top: -70px; right: -20px; width: 340px; height: 340px; border-radius: 50%; background: radial-gradient(circle, rgba(99,102,241,.14), rgba(139,92,246,0) 70%); pointer-events: none; }
.mail-page-header { display: flex; align-items: flex-end; justify-content: space-between; min-height: 108px; }
.mail-page-header h1 { color: var(--color-text, #0f172a); font-weight: 850; letter-spacing: -.035em; line-height: 1.08; }
.mail-page-header p { max-width: 680px; line-height: 1.6; }
.mail-eyebrow { display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .65rem; border: 1px solid rgba(99,102,241,.18); border-radius: 999px; background: rgba(238,242,255,.76); }
.mail-login-card, .mail-saved-accounts, .mail-content, .mail-topbar { border-color: rgba(148,163,184,.18); box-shadow: 0 18px 50px rgba(15,23,42,.075), 0 2px 8px rgba(15,23,42,.035); }
.mail-login-card { position: relative; overflow: hidden; background: linear-gradient(145deg, var(--bg-card,#fff) 0%, rgba(248,250,252,.9) 100%); }
.mail-login-card::after { content: ''; position: absolute; top: 0; right: 0; width: 145px; height: 145px; background: linear-gradient(135deg, rgba(99,102,241,.10), transparent 68%); pointer-events: none; }
.mail-login-icon { box-shadow: 0 12px 28px rgba(99,102,241,.28); transform: rotate(-2deg); }
.mail-input, .mail-account-select, .mail-search-input, .mail-compose-body { transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease; }
.mail-input:hover, .mail-account-select:hover { border-color: #c4b5fd; }
.mail-submit, .mail-compose-button { border: 0; background: linear-gradient(135deg,#4f46e5,#7c3aed); box-shadow: 0 10px 24px rgba(99,102,241,.22); }
.mail-account-card { transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
.mail-account-card:hover { transform: translateY(-2px); border-color: rgba(99,102,241,.3); box-shadow: 0 12px 26px rgba(15,23,42,.08); }
.mail-account-avatar, .mail-sender-avatar { background: linear-gradient(145deg,#eef2ff,#ede9fe); box-shadow: inset 0 0 0 1px rgba(99,102,241,.08); }
.mail-topbar { background: linear-gradient(180deg, var(--bg-card,#fff), rgba(248,250,252,.96)); }
.mail-back-accounts, .mail-link-button, .mail-folder-link, .mail-icon-button, .mail-attachment { transition: color .2s ease, background-color .2s ease, border-color .2s ease, transform .2s ease, box-shadow .2s ease; }
.mail-back-accounts:hover { background: rgba(238,242,255,.72); }
.mail-folder-link:hover { color: #4f46e5; background: rgba(238,242,255,.72); transform: translateY(-1px); }
.mail-folder-link.active { box-shadow: inset 0 -3px 0 #6366f1; }
.mail-list-toolbar { background: linear-gradient(180deg, rgba(248,250,252,.88), rgba(255,255,255,.58)); }
.mail-list-toolbar h2 { color: var(--color-text,#0f172a); font-size: 1.25rem; font-weight: 800; letter-spacing: -.02em; }
.mail-search { background: var(--color-surface-2,#f8fafc); transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease; }
.mail-search:focus-within { border-color: #6366f1; background: var(--color-surface,#fff); box-shadow: 0 0 0 4px rgba(99,102,241,.1); }
.mail-message-row { transition: background-color .16s ease, transform .16s ease, box-shadow .16s ease; }
.mail-message-row:hover { position: relative; z-index: 1; transform: translateX(3px); box-shadow: -3px 0 0 #6366f1; }
.mail-message-row.unread { background: linear-gradient(90deg, rgba(238,242,255,.94), rgba(248,250,252,.45)); }
.mail-detail-header { background: linear-gradient(180deg, rgba(248,250,252,.88), transparent); }
.mail-detail-header h2 { color: var(--color-text,#0f172a); font-weight: 800; letter-spacing: -.025em; line-height: 1.3; }
.mail-icon-button:hover { color: #4f46e5; border-color: #c7d2fe; background: #eef2ff; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(99,102,241,.12); }
.mail-attachment:hover { color: #4f46e5; border-color: #c7d2fe; background: #eef2ff; transform: translateY(-1px); }
.mail-compose-header { background: linear-gradient(90deg, rgba(238,242,255,.7), transparent); }
.mail-compose-fields { background: rgba(248,250,252,.54); }
.mail-compose-body { font: 15px/1.7 var(--font-sans,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif); }
.mail-compose-footer { background: rgba(248,250,252,.7); }
.mail-modal { overflow: hidden; animation: mail-modal-in .2s ease-out; }
.mail-modal-header { background: linear-gradient(90deg, rgba(238,242,255,.78), transparent); }
@keyframes mail-modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

[data-theme="dark"] .mail-eyebrow { color: #a5b4fc; border-color: rgba(129,140,248,.28); background: rgba(49,46,129,.28); }
[data-theme="dark"] .mail-login-card, [data-theme="dark"] .mail-topbar { background: linear-gradient(145deg, var(--color-surface), rgba(30,41,59,.94)); }
[data-theme="dark"] .mail-account-card, [data-theme="dark"] .mail-list-toolbar, [data-theme="dark"] .mail-compose-fields, [data-theme="dark"] .mail-compose-footer, [data-theme="dark"] .mail-detail-header { background: rgba(30,41,59,.72); border-color: var(--color-border); }
[data-theme="dark"] .mail-account-avatar, [data-theme="dark"] .mail-sender-avatar { color: #c7d2fe; background: linear-gradient(145deg,#312e81,#4c1d95); }
[data-theme="dark"] .mail-message-row.unread { background: linear-gradient(90deg,rgba(49,46,129,.42),rgba(30,41,59,.3)); }
[data-theme="dark"] .mail-message-row.unread .mail-message-sender, [data-theme="dark"] .mail-message-row.unread .mail-message-subject strong, [data-theme="dark"] .mail-detail-header h2 { color: var(--color-text); }
[data-theme="dark"] .mail-icon-button, [data-theme="dark"] .mail-attachment, [data-theme="dark"] .mail-modal { color: var(--color-text-soft); border-color: var(--color-border); background: var(--color-surface); }
[data-theme="dark"] .mail-password-toggle:hover, [data-theme="dark"] .mail-password-toggle:focus-visible { color: #c7d2fe; background: rgba(49,46,129,.42); }
[data-theme="dark"] .mail-compose-header, [data-theme="dark"] .mail-modal-header { background: linear-gradient(90deg,rgba(49,46,129,.34),transparent); }
body:has(.mail-page) #fab-root { display: none !important; }
@media (max-width: 900px) {
  .mail-account-layout { grid-template-columns: 1fr; }
  .mail-topbar-main { grid-template-columns: 1fr auto; }
  .mail-active-account { grid-column: 1 / -1; grid-row: 2; grid-template-columns: auto minmax(0,1fr); }
  .mail-folders { grid-template-columns: repeat(4,1fr); }
  .mail-folder-link { grid-template-columns: 1fr; justify-items: center; font-size: .7rem; }
  .mail-folder-link strong { position: absolute; margin-left: 25px; margin-top: -22px; }
  .mail-message-row { grid-template-columns: 38px minmax(0,1fr) auto; }
  .mail-message-subject { grid-column: 2 / 4; }
  .mail-list-toolbar { align-items: stretch; flex-direction: column; }
  .mail-search { width: 100%; }
}
@media (max-width: 560px) {
  .mail-login-card, .mail-saved-accounts { padding: 1rem; }
  .mail-topbar-main { grid-template-columns: 1fr; }
  .mail-active-account { grid-column: auto; grid-row: auto; grid-template-columns: 1fr; }
  .mail-compose-button { width: 100%; }
  .mail-folders { grid-template-columns: repeat(2,1fr); }
  .mail-account-actions { justify-content: space-between; }
  .mail-detail-actions { align-items: flex-start; }
  .mail-detail-actions > div { flex-wrap: wrap; justify-content: flex-end; }
  .mail-detail-meta { grid-template-columns: 42px 1fr; }
  .mail-detail-meta time { grid-column: 2; }
  .mail-compose-footer { align-items: stretch; flex-direction: column; gap: 1rem; }
  .mail-file-input { display: block; margin: .5rem 0 0; }
}
