:root {
    --blue: #3b82f6;
    --blue-dark: #2563eb;
    --purple: #8b5cf6;
    --cyan: #22d3ee;
    --bg: #f3f6fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --line: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
    --green: #16a34a;
    --amber: #d97706;
    --red: #dc2626;
    --shadow: 0 18px 50px rgba(15, 23, 42, .08);
    --glass: rgba(255, 255, 255, .76);
    --glass-strong: rgba(255, 255, 255, .9);
}

:root[data-theme="dark"] {
    --bg: #020617;
    --panel: rgba(15, 23, 42, .72);
    --panel-soft: rgba(30, 41, 59, .66);
    --line: #334155;
    --text: #e5eefb;
    --muted: #94a3b8;
    --shadow: 0 18px 50px rgba(2, 6, 23, .45);
    --glass: rgba(15, 23, 42, .66);
    --glass-strong: rgba(15, 23, 42, .84);
}


* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 15% 10%, rgba(59,130,246,.2), transparent 28%),
        radial-gradient(circle at 88% 72%, rgba(34,211,238,.14), transparent 28%),
        linear-gradient(180deg, rgba(255,255,255,.08), transparent 34%),
        var(--bg);
    color: var(--text);
    overflow-x: hidden;
}
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: .52;
    background-image:
        linear-gradient(rgba(148,163,184,.09) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148,163,184,.09) 1px, transparent 1px),
        repeating-linear-gradient(118deg, rgba(59,130,246,.08) 0 1px, transparent 1px 22px);
    background-size: 58px 58px, 58px 58px, 360px 360px;
    mask-image: linear-gradient(180deg, rgba(0,0,0,.92), transparent 88%);
}

button, .button, input, select, textarea { font: inherit; }
button, .button {
    border: 1px solid rgba(148, 163, 184, .2);
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--text);
    background: linear-gradient(180deg, var(--glass-strong), var(--glass));
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    gap: 6px;
    transition: transform .15s ease, filter .15s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
    backdrop-filter: blur(14px);
}
button:hover, .button:hover { filter: brightness(1.02); transform: translateY(-1px); border-color: rgba(96,165,250,.44); box-shadow: 0 12px 24px rgba(15,23,42,.12); }
.primary { background: linear-gradient(135deg, #0f172a, var(--blue), var(--cyan)); color: white; box-shadow: 0 10px 24px rgba(37, 99, 235, .22); }
:root[data-theme="dark"] .primary { background: linear-gradient(135deg, #e0f2fe, #93c5fd, #818cf8); color: #07111f; }
.warning { background: linear-gradient(135deg, #f59e0b, #facc15); color: #111827; }
.danger { background: linear-gradient(135deg, #dc2626, #f87171); color: white; }
.ghost { background: rgba(148,163,184,.08); color: var(--muted); }
.small { padding: 7px 10px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.full { width: 100%; }

input, select, textarea {
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--panel);
    color: var(--text);
    min-height: 40px;
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea { resize: vertical; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 92px minmax(0, 1fr); }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background:
        radial-gradient(circle at 20% 0%, rgba(56, 189, 248, .28), transparent 32%),
        repeating-linear-gradient(116deg, rgba(255,255,255,.045) 0 1px, transparent 1px 18px),
        linear-gradient(180deg, #050914 0%, #0f172a 52%, #111827 100%);
    color: white;
    padding: 18px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    border-right: 1px solid rgba(255,255,255,.08);
    box-shadow: 18px 0 44px rgba(2,6,23,.18);
}
.brand-mark {
    width: 60px;
    height: 60px;
    border-radius: 0;
    display: grid;
    place-items: center;
    background: transparent;
    box-shadow: none;
    transition: transform .18s ease, filter .18s ease;
}
.brand-mark:hover {
    transform: translateY(-1px);
    filter: drop-shadow(0 12px 20px rgba(96,165,250,.28));
}
.brand-mark img {
    width: 56px;
    height: 56px;
    display: block;
}
.brand-logo, .login-logo { width: 48px; height: 48px; display: block; }
.brand h1 { font-size: 22px; letter-spacing: .4px; line-height: 1.1; margin: 0; }
.brand p { margin: 5px 0 0; color: rgba(255, 255, 255, .74); font-size: 13px; }
.rail-nav {
    width: 100%;
    display: grid;
    gap: 12px;
    margin-top: 10px;
}
.rail-nav a, .rail-logout {
    position: relative;
    min-height: 60px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 7px;
    color: rgba(255, 255, 255, .82);
    text-decoration: none;
    background: transparent;
    border: 1px solid transparent;
    font-size: 13px;
    line-height: 1;
    transition: background .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.rail-nav a:hover, .rail-logout:hover {
    background: rgba(255,255,255,.08);
    border-color: rgba(255,255,255,.1);
    color: #fff;
}
.rail-nav a.active {
    background:
        linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,.07)),
        radial-gradient(circle at 50% 0, rgba(96,165,250,.42), transparent 58%);
    border-color: rgba(147,197,253,.42);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 16px 32px rgba(37,99,235,.22), inset 0 1px 0 rgba(255,255,255,.18);
}
.rail-nav a.active::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 16px;
    bottom: 16px;
    width: 3px;
    border-radius: 999px;
    background: linear-gradient(180deg, #60a5fa, #22d3ee);
    box-shadow: 0 0 14px rgba(34,211,238,.78);
}
.rail-nav a.active::after {
    content: "";
    position: absolute;
    top: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e0f2fe;
    box-shadow: 0 0 18px rgba(34,211,238,.9);
}
.rail-nav a.active .nav-icon { margin-top: 4px; }
.rail-nav span, .rail-logout span { display: block; }
.rail-logout {
    width: 100%;
    margin-top: auto;
}
.nav-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
    flex: 0 0 auto;
}
.main { min-width: 0; padding: 28px 34px 40px; }

.page-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
.page-header h2 { margin: 0 0 6px; font-size: 30px; letter-spacing: -.4px; }
.page-header p { margin: 0; color: var(--muted); }
.page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
.top-theme-toggle {
    position: static !important;
}
.user-chip {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid rgba(148,163,184,.24);
    border-radius: 10px;
    background: linear-gradient(180deg, var(--glass-strong), var(--glass));
    padding: 5px 11px 5px 6px;
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
}
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    overflow: hidden;
}
.avatar img {
    width: 100%;
    height: 100%;
    display: block;
}
.avatar-orbit { animation: avatar-float 4.5s ease-in-out infinite; }
.user-chip strong,
.user-chip small {
    display: block;
    line-height: 1.1;
}
.user-chip small {
    color: var(--muted);
    margin-top: 3px;
    font-size: 12px;
}
.stats-grid, .mail-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat { background: var(--glass); border: 1px solid rgba(148,163,184,.22); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.stat span { color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 8px; font-size: 30px; }
.stat.mini strong { font-size: 20px; overflow-wrap: anywhere; }

.toolbar, .bulk-bar, .pagination-bar { background: var(--glass); border: 1px solid rgba(148,163,184,.22); border-radius: 16px; padding: 16px; display: flex; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 18px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.filters, .actions, .bulk-actions, .bulk-left, .pagination-actions, .row-actions, .inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.bulk-bar { position: sticky; top: 12px; z-index: 5; }
.bulk-actions input { width: 150px; }
.checkline { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); }
.table-card { background: var(--glass); border: 1px solid rgba(148,163,184,.22); border-radius: 16px; overflow: auto; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.account-table-card { margin-bottom: 0; }
.pagination-bar { color: var(--muted); font-size: 13px; margin-top: 12px; }
.page-indicator { color: var(--text); min-width: 92px; text-align: center; }
.disabled { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 14px; }
th { background: var(--panel-soft); color: #475569; font-weight: 700; position: sticky; top: 0; z-index: 1; }
tr:last-child td { border-bottom: 0; }
.check-col { width: 44px; }
.mono { font-family: Consolas, "Courier New", monospace; }
.tag { display: inline-flex; align-items: center; min-height: 24px; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.tag.blue { background: #dbeafe; color: #1d4ed8; }
.tag.green { background: #dcfce7; color: #166534; }
.tag.amber { background: #fef3c7; color: #92400e; }
.tag.red { background: #fee2e2; color: #991b1b; }
.tag.gray { background: #e5e7eb; color: #4b5563; }
.empty { color: var(--muted); text-align: center; padding: 44px; }
.row-actions.wrap { align-items: flex-start; }
.row-actions form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.email-copy-cell { display: flex; align-items: center; gap: 8px; min-width: 260px; }
.email-copy-cell .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-button { min-height: 28px; padding: 5px 9px; border-radius: 7px; color: #2563eb; background: #dbeafe; font-size: 12px; flex-shrink: 0; }
.active-filter { background: #fee2e2; color: #991b1b; }
.copy-toast { position: fixed; top: 18px; right: 18px; z-index: 50; transform: translateY(-8px); opacity: 0; background: #111827; color: white; border-radius: 10px; padding: 10px 14px; box-shadow: 0 14px 35px rgba(15, 23, 42, .2); transition: opacity .18s ease, transform .18s ease; }
.copy-toast.show { transform: translateY(0); opacity: 1; }
.notice { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; border-radius: 14px; padding: 14px 16px; margin-bottom: 18px; }
.notice.soft { background: var(--panel-soft); border-color: var(--line); color: var(--text); line-height: 1.7; white-space: pre-wrap; }
.notice.compact { margin: 0; }
.permission-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.note-title { padding: 11px 12px; border-radius: 10px; background: var(--panel-soft); color: var(--muted); overflow-wrap: anywhere; }

.mail-layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); min-height: 660px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.mail-list { border-right: 1px solid var(--line); background: var(--panel-soft); overflow-y: auto; }
.mail-item { display: grid; gap: 5px; padding: 15px 16px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.mail-item:hover, .mail-item.active { background: #e8f0fe; }
.mail-item strong, .mail-item span, .mail-item small, .mail-item em { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-item strong { font-size: 14px; }
.mail-item span, .mail-item small, .mail-item em { color: var(--muted); font-size: 12px; font-style: normal; }
.mail-detail { overflow-y: auto; background: var(--panel); }
.mail-card { border-bottom: 1px solid var(--line); padding: 22px; }
.mail-card header { border-bottom: 1px solid var(--line); margin-bottom: 18px; padding-bottom: 14px; }
.mail-card h3 { margin: 0 0 10px; font-size: 20px; }
.mail-card p { color: var(--muted); margin: 5px 0; font-size: 13px; }
.mail-card iframe { width: 100%; min-height: 540px; border: 0; background: var(--panel); }
.mail-empty { min-height: 620px; display: grid; place-content: center; gap: 8px; color: var(--muted); text-align: center; }
.mail-empty strong { color: var(--text); font-size: 18px; }
.mail-toolbar .actions form { display: inline-flex; }

dialog { border: 0; border-radius: 18px; padding: 0; width: min(760px, calc(100vw - 28px)); box-shadow: 0 24px 80px rgba(15, 23, 42, .25); }
dialog::backdrop { background: rgba(15, 23, 42, .42); backdrop-filter: blur(3px); }
.dialog-form { padding: 20px; display: grid; gap: 14px; }
.dialog-form header { display: flex; justify-content: space-between; align-items: center; }
.dialog-form h3 { margin: 0; }
.dialog-form label { display: grid; gap: 7px; color: #475569; font-size: 13px; font-weight: 700; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.flash-stack { position: fixed; z-index: 20; top: 16px; right: 18px; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.flash { background: #111827; color: white; border-radius: 12px; padding: 11px 15px; box-shadow: 0 10px 30px rgba(15, 23, 42, .18); }
.flash.success { background: var(--green); }
.flash.error { background: var(--red); }

.login-page { min-height: 100vh; padding: 24px; background: radial-gradient(circle at 16% 14%, rgba(59, 130, 246, .28), transparent 28%), radial-gradient(circle at 84% 80%, rgba(124, 58, 237, .24), transparent 32%), linear-gradient(135deg, #eef2ff, #eff6ff 48%, #f8fafc); }
.atlas-login { display: grid; grid-template-columns: minmax(0, 560px) minmax(340px, 430px); align-items: center; justify-content: center; gap: 34px; }
.login-hero { position: relative; min-height: 420px; border-radius: 28px; padding: 38px; background: linear-gradient(145deg, rgba(15,23,42,.96), rgba(30,41,59,.88)); color: white; overflow: hidden; box-shadow: 0 30px 80px rgba(15,23,42,.25); }
.hero-orb { position: absolute; width: 280px; height: 280px; border-radius: 50%; right: -90px; top: -80px; background: linear-gradient(135deg, rgba(56,189,248,.7), rgba(168,85,247,.55)); filter: blur(2px); }
.login-hero .login-logo { position: relative; width: 76px; height: 76px; }
.login-hero h1 { position: relative; font-size: 54px; margin: 22px 0 12px; letter-spacing: -.8px; }
.login-hero p { position: relative; max-width: 430px; margin: 0; color: rgba(255,255,255,.76); line-height: 1.8; }
.hero-pills { position: relative; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.hero-pills span { border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.08); border-radius: 999px; padding: 8px 12px; color: rgba(255,255,255,.86); }
.login-card { width: min(430px, 100%); background: rgba(255,255,255,.92); border: 1px solid rgba(226,232,240,.9); border-radius: 24px; padding: 30px; box-shadow: 0 22px 70px rgba(15, 23, 42, .13); display: grid; gap: 16px; backdrop-filter: blur(10px); }
.login-card h2 { margin: 0 0 5px; font-size: 30px; }
.login-card p, .hint { color: var(--muted); margin: 0; font-size: 13px; }
.login-card label { display: grid; gap: 8px; color: #475569; font-size: 14px; font-weight: 700; }

@media (max-width: 1100px) {
    .stats-grid, .mail-summary-grid { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
    .permission-cards { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; padding: 18px; }
    .nav { grid-template-columns: repeat(4, auto); overflow-x: auto; }
    .side-note { display: none; }
    .main { padding: 20px; }
    .toolbar, .bulk-bar, .page-header, .pagination-bar { align-items: stretch; flex-direction: column; }
    .bulk-bar { position: static; }
    .stats-grid, .grid-2, .mail-layout, .mail-summary-grid { grid-template-columns: 1fr; }
    .mail-list { border-right: 0; border-bottom: 1px solid var(--line); max-height: 300px; }
    .atlas-login { grid-template-columns: 1fr; }
    .login-hero { min-height: 300px; }
}

@media (max-width: 720px) {
    .main { padding: 16px; }
    .page-header h2 { font-size: 25px; }
    .page-actions { justify-content: flex-start; width: 100%; }
    .user-chip { max-width: 100%; }
    .user-chip > div { min-width: 0; }
    .filters, .actions, .bulk-actions, .pagination-actions, .inline-form { width: 100%; align-items: stretch; }
    .filters > *, .actions > *, .bulk-actions > *, .inline-form > * { width: 100%; }
    table { min-width: 0; }
    thead { display: none; }
    tr { display: grid; padding: 12px; border-bottom: 1px solid var(--line); }
    td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 0; padding: 8px 6px; }
    td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 700; }
    td.check-col::before { content: '选择'; }
    .email-copy-cell { min-width: 0; justify-content: space-between; }
    .row-actions { justify-content: flex-end; }
    .row-actions::before { content: attr(data-label); color: var(--muted); margin-right: auto; }
    .login-page { padding: 14px; }
    .login-hero { display: none; }
    .login-card { border-radius: 20px; }
}


html, body { background: var(--bg); color: var(--text); }
a { color: inherit; }
.theme-toggle {
    position: fixed;
    top: 16px;
    right: 18px;
    z-index: 60;
    min-height: 40px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(10px);
    box-shadow: 0 14px 35px rgba(15, 23, 42, .12);
    color: var(--text);
}
:root[data-theme="dark"] .theme-toggle {
    background: rgba(17,24,39,.92);
    color: var(--text);
}

input, select, textarea {
    background: var(--panel);
    color: var(--text);
    border-color: var(--line);
}
button, .button { border: 1px solid transparent; }
.small.ghost, .ghost {
    background: var(--panel-soft);
    color: var(--muted);
}
.table-card, .toolbar, .bulk-bar, .pagination-bar, .mail-layout, .stat, .login-card {
    background: var(--panel);
    box-shadow: var(--shadow);
}
.account-table tbody tr { min-height: 74px; }
.account-table td { height: 74px; }
.note-action-cell { min-width: 150px; }
.note-action-cell, .row-actions { vertical-align: middle; }
.note-action-cell .small { min-width: 92px; }
.row-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-jump-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
}
.page-jump-form label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    color: var(--muted);
    font-size: 13px;
}
.page-jump-input {
    width: 78px;
    min-height: 32px;
    padding: 6px 10px;
    text-align: center;
}
.copy-toast.inline {
    position: absolute;
    top: 18px;
    right: auto;
    left: 18px;
    transform: translateY(-6px);
    pointer-events: none;
}
:root[data-theme="dark"] .copy-toast {
    background: #020617;
    color: #f8fafc;
}
:root[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #1d4ed8 0%, #312e81 100%);
}
:root[data-theme="dark"] th {
    background: #182132;
    color: #cbd5e1;
}
:root[data-theme="dark"] .mail-list,
:root[data-theme="dark"] .note-title,
:root[data-theme="dark"] .notice.soft,
:root[data-theme="dark"] .tag.gray,
:root[data-theme="dark"] .copy-button,
:root[data-theme="dark"] .small.ghost,
:root[data-theme="dark"] .ghost,
:root[data-theme="dark"] button,
:root[data-theme="dark"] .button {
    background: var(--panel-soft);
    color: var(--text);
}
:root[data-theme="dark"] .primary { background: var(--blue); color: white; }
:root[data-theme="dark"] .warning { background: #f59e0b; color: white; }
:root[data-theme="dark"] .danger { background: var(--red); color: white; }
:root[data-theme="dark"] .mail-item:hover,
:root[data-theme="dark"] .mail-item.active { background: #23314a; }
:root[data-theme="dark"] .mail-detail,
:root[data-theme="dark"] .mail-card iframe { background: var(--panel); }
:root[data-theme="dark"] dialog { background: var(--panel); color: var(--text); }
:root[data-theme="dark"] .login-card {
    background: rgba(17,24,39,.88);
    border-color: rgba(51,65,85,.9);
}
:root[data-theme="dark"] .login-page {
    background: radial-gradient(circle at 16% 14%, rgba(59, 130, 246, .20), transparent 28%), radial-gradient(circle at 84% 80%, rgba(124, 58, 237, .18), transparent 32%), linear-gradient(135deg, #0f172a, #111827 48%, #020617);
}
@media (max-width: 900px) {
    .theme-toggle { top: 12px; right: 12px; }
}
@media (max-width: 720px) {
    .page-jump-form { width: 100%; justify-content: space-between; }
    .page-jump-form label { width: 100%; justify-content: space-between; }
    .page-jump-input { width: 88px; }
    .theme-toggle { padding: 8px 12px; min-height: 36px; }
}


/* 2026-06-08 UI fixes */

.brand {
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.brand-main {
    display: flex;
    gap: 12px;
    align-items: center;
    min-width: 0;
}
.theme-toggle {
    position: fixed;
    top: 16px;
    right: 18px;
    z-index: 60;
    min-height: 40px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(10px);
    box-shadow: 0 14px 35px rgba(15, 23, 42, .12);
    color: var(--text);
}
.theme-toggle.in-sidebar {
    position: static;
    top: auto;
    right: auto;
    min-height: 34px;
    padding: 7px 12px;
    flex-shrink: 0;
}
.account-table tbody tr {
    min-height: 74px;
    box-shadow: inset 0 -1px 0 var(--line);
}
.account-table tbody tr:last-child {
    box-shadow: none;
}
.account-table tbody td {
    height: 74px;
    border-bottom: 0 !important;
}
.copy-toast.inline {
    position: fixed;
    top: 18px;
    left: 18px;
    right: auto;
    transform: translateY(-6px);
    pointer-events: none;
}
.primary,
button.primary,
.button.primary {
    background: var(--blue) !important;
    color: #fff !important;
    border-color: transparent !important;
}
.warning,
button.warning,
.button.warning {
    background: #f59e0b !important;
    color: #fff !important;
    border-color: transparent !important;
}
.danger,
button.danger,
.button.danger {
    background: var(--red) !important;
    color: #fff !important;
    border-color: transparent !important;
}
:root[data-theme="dark"] .theme-toggle,
:root[data-theme="dark"] .theme-toggle.in-sidebar {
    background: rgba(17,24,39,.92);
    color: var(--text);
    border-color: var(--line);
}
@media (max-width: 900px) {
    .brand {
        align-items: flex-start;
        flex-direction: column;
    }
    .theme-toggle.in-sidebar {
        position: static;
    }
}
@media (max-width: 720px) {
    .theme-toggle:not(.in-sidebar) {
        top: 12px;
        right: 12px;
        padding: 8px 12px;
        min-height: 36px;
    }
}


/* Remember login checkbox */
.login-card label.remember-line {
    display: flex;
    grid-template-columns: none;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 9px;
    margin-top: -2px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.login-card label.remember-line input {
    width: 16px;
    height: 16px;
    min-height: 16px;
    margin: 0;
    accent-color: var(--blue);
    cursor: pointer;
}
.login-card label.remember-line span {
    user-select: none;
}

/* IMAP module UI */
.imap-config-box {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-soft);
}
.imap-config-box strong {
    color: var(--text);
    font-size: 14px;
}
.imap-hint {
    line-height: 1.6;
}
.account-table .tag.amber {
    white-space: nowrap;
}
:root[data-theme="dark"] .imap-config-box {
    background: var(--panel-soft);
    border-color: var(--line);
}


/* Lazy mail body loading */
.mail-item em.header-only {
    color: #d97706;
    font-weight: 700;
}
.mail-item em.loaded {
    color: #16a34a;
    font-weight: 700;
}
:root[data-theme="dark"] .mail-item em.header-only {
    color: #fbbf24;
}
:root[data-theme="dark"] .mail-item em.loaded {
    color: #4ade80;
}


/* QR code button and modal */
.qr-button {
    min-height: 28px;
    padding: 5px 9px;
    border-radius: 7px;
    color: #7c3aed;
    background: #ede9fe;
    font-size: 12px;
    flex-shrink: 0;
}
.qr-button:hover {
    filter: brightness(.98);
}
.qr-dialog {
    width: min(420px, calc(100vw - 28px));
}
.qr-box {
    text-align: center;
}
.qr-box header {
    text-align: left;
}
.qr-email {
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--panel-soft);
    color: var(--text);
    overflow-wrap: anywhere;
}
.qr-image-wrap {
    display: grid;
    place-items: center;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #ffffff;
}
.qr-image-wrap img {
    width: min(240px, 70vw);
    height: auto;
    display: block;
}
.qr-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
:root[data-theme="dark"] .qr-button {
    color: #ddd6fe;
    background: #3b2a68;
}

/* Atlas control-center aligned navigation and theme controls */
.theme-toggle,
.theme-toggle.in-sidebar {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 6px;
    border-radius: 14px;
    display: inline-grid;
    place-items: center;
    background: linear-gradient(180deg, var(--glass-strong), var(--glass));
    border: 1px solid rgba(148,163,184,.24);
}
.theme-toggle:not(.top-theme-toggle):not(.in-sidebar) {
    display: none;
}
.theme-toggle.in-sidebar {
    margin-left: auto;
}
.theme-glyph {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: #f8fafc;
    color: #020617;
    font-weight: 900;
    line-height: 1;
}
.theme-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
:root[data-theme="dark"] .theme-glyph {
    background: #e0f2fe;
    color: #020617;
}
@keyframes avatar-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-1px); }
}

/* Match Atlas Control Center rail navigation */
.shell { grid-template-columns: 92px minmax(0, 1fr) !important; }
.sidebar {
    position: sticky !important;
    top: 0 !important;
    height: 100vh !important;
    padding: 18px 10px !important;
    align-items: center !important;
}
.brand-mark { display: grid !important; }
.rail-nav { width: 100%; display: grid; gap: 12px; margin-top: 10px; }
.rail-nav a,
.rail-logout {
    min-height: 60px;
    display: grid !important;
    place-items: center;
    align-content: center;
    gap: 7px;
}
.rail-logout { margin-top: auto; }
.theme-toggle.in-sidebar { display: none !important; }

@media (max-width: 900px) {
    .shell {
        display: block !important;
        min-height: 100vh;
    }
    .sidebar {
        position: fixed !important;
        left: 10px;
        right: 10px;
        bottom: 10px;
        top: auto !important;
        z-index: 40;
        height: 70px !important;
        min-height: 70px;
        flex-direction: row;
        justify-content: space-between;
        padding: 8px !important;
        border-radius: 18px;
        border: 1px solid rgba(255,255,255,.1);
        box-shadow: 0 18px 44px rgba(0,0,0,.28);
        backdrop-filter: blur(18px);
    }
    .brand-mark { width: 48px; height: 48px; }
    .brand-mark img { width: 46px; height: 46px; }
    .rail-nav {
        flex: 1;
        display: flex;
        justify-content: center;
        gap: 4px;
        margin: 0;
        overflow-x: auto;
    }
    .rail-nav a {
        min-width: 54px;
        min-height: 52px;
        padding: 6px;
        font-size: 12px;
    }
    .rail-nav a.active::before,
    .rail-nav a.active::after { display: none; }
    .rail-logout {
        width: auto;
        min-width: 48px;
        min-height: 52px;
        margin: 0;
        padding: 0 6px;
        font-size: 12px;
    }
    .main { padding-bottom: 92px !important; }
}

@media (max-width: 420px) {
    .brand-mark { display: none !important; }
    .rail-logout span { display: none; }
    .rail-nav a { min-width: 56px; }
}
