* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Inter", "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
    background: #0f1115;
    color: #eef2f7;
}
body.login-page {
    background: #f6f8fc;
    color: #202124;
}
body.login-page .content {
    background: transparent;
    padding: 0;
}
body.login-page .login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px 60px;
}
body.login-page .login-card {
    width: min(448px, 100%);
    background: #ffffff;
    border: 1px solid #dadce0;
    border-radius: 12px;
    padding: 32px 32px 24px;
    box-shadow: none;
}
body.login-page .login-header {
    margin-bottom: 16px;
}
body.login-page .login-subtitle {
    margin-top: 16px;
    font-weight: 600;
}
body.login-page .brand-pill {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    background: #1d4ed8;
    color: #fff;
    font-size: 12px;
    letter-spacing: 0.4px;
    margin-bottom: 12px;
}
body.login-page .login-panel .card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}
@media (max-width: 900px) {
    body.login-page .login-card {
        padding: 20px;
    }
}
body.login-page .card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
}
body.login-page .input,
body.login-page .textarea,
body.login-page select {
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #d0d7e2;
}
body.login-page .muted {
    color: #64748b;
}
body.login-page .btn {
    background: #2563eb;
}
body.login-page .btn-outline {
    border-color: #cbd5e1;
    color: #0f172a;
}
.login-topbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    background: transparent;
    color: #5f6368;
    font-weight: 600;
    letter-spacing: 0.2px;
}
.login-topbar-logo {
    font-size: 16px;
}
.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}
.login-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #1a73e8;
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
}
.login-title {
    font-size: 24px;
    font-weight: 500;
}
.login-subtitle {
    color: #5f6368;
    font-size: 14px;
}
.login-field {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
}
.login-field label {
    font-size: 12px;
    color: #5f6368;
}
.login-input {
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid #dadce0;
}
.login-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
}
.login-hint {
    color: #5f6368;
    font-size: 12px;
}
.login-submit {
    padding: 10px 18px;
    background: #1a73e8;
    border-radius: 6px;
}
.login-saved-title {
    margin-top: 18px;
    font-weight: 500;
    color: #202124;
}
.login-saved-list .account-row {
    border-radius: 8px;
}
.warning {
    color: #f59e0b;
    margin: 8px 0;
}
.login-wrap .card {
    padding: 18px;
}
.account-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #202734;
    background: #151a23;
}
body.login-page .account-row {
    background: #ffffff;
    border: 1px solid #e2e8f0;
}
.account-label {
    flex: 1;
    font-weight: 500;
}
a { color: inherit; text-decoration: none; }
.app {
    display: grid;
    grid-template-columns: 240px 1fr 360px;
    min-height: 100vh;
}
.sidebar {
    background: #1b2029;
    padding: 20px;
    border-right: 1px solid #2a3140;
}
.content {
    padding: 20px 24px;
}
.details {
    border-left: 1px solid #2a3140;
    padding: 20px 24px;
    background: #141821;
}
.title {
    font-size: 20px;
    margin: 0 0 10px;
}
.muted {
    color: #94a3b8;
    font-size: 13px;
}
.btn {
    display: inline-block;
    padding: 8px 12px;
    background: #3b82f6;
    color: #fff;
    border-radius: 8px;
    border: none;
    cursor: pointer;
}
.btn-outline {
    background: transparent;
    border: 1px solid #334155;
    color: #e2e8f0;
}
.list {
    margin: 16px 0;
    display: grid;
    gap: 10px;
}
.card {
    padding: 12px 14px;
    border-radius: 10px;
    background: #1b2029;
    border: 1px solid #252c3a;
}
.message-link { display: block; }
.message-link.active { outline: 2px solid #3b82f6; border-radius: 8px; }
.html-body img { max-width: 100%; height: auto; }
.html-body a { color: #60a5fa; }
.tag { display: inline-block; padding: 4px 8px; border-radius: 999px; background: #202735; font-size: 12px; color: #cbd5f5; }
.compact-list .message-card { padding: 8px 10px; }
.compact-list .message-card .muted { display: none; }
.show-previews .message-card .muted { display: block; }
.input, .textarea, select, button {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #2f3848;
    background: #0f1219;
    color: #e2e8f0;
    font-family: inherit;
}
.textarea { min-height: 140px; resize: vertical; }
.row { display: grid; gap: 8px; margin-bottom: 10px; }
.row-2 { grid-template-columns: repeat(2, 1fr); }
.nav-link { display: block; padding: 8px 10px; border-radius: 8px; }
.nav-link.active { background: #273044; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.toolbar-search {
    align-items: center;
    gap: 10px;
    background: #151a23;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid #273044;
}
.sidebar .list { gap: 6px; }
.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.message-card {
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.message-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.smtp-details summary {
    cursor: pointer;
    color: #60a5fa;
    margin-top: 6px;
}
.smtp-details pre {
    white-space: pre-wrap;
    background: #111827;
    padding: 8px;
    border-radius: 8px;
    margin-top: 6px;
}
.title { font-size: 20px; }
.modal-card { padding: 18px; }
.error { color: #fca5a5; margin: 8px 0; }
.success { color: #86efac; margin: 8px 0; }
.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(5, 8, 15, 0.6);
    padding: 20px;
    z-index: 1000;
}
.modal.open { display: flex; }
.compose-open .modal { display: flex; }
.modal-card {
    width: 100%;
    max-width: 640px;
    background: #1b2029;
    border: 1px solid #2a3140;
    border-radius: 12px;
    padding: 16px;
}
.sending .modal-card {
    opacity: 0.8;
}
.sending .btn {
    pointer-events: none;
    opacity: 0.7;
}
.sending .modal-card::after {
    content: '';
    position: absolute;
    top: 20px;
    right: 20px;
    width: 18px;
    height: 18px;
    border: 2px solid #3b82f6;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.modal-card { position: relative; }
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.sidebar {
    background: #161b22;
}
.content {
    background: #0f1115;
}
.details {
    background: #0f1115;
}
.btn {
    background: #2563eb;
}
.btn-outline {
    background: transparent;
    border: 1px solid #334155;
    color: #e2e8f0;
}
.card {
    box-shadow: 0 1px 0 rgba(255,255,255,0.04);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.modal-title { font-size: 18px; margin: 0; }
.modal-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
}
.fab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: #168de2;
    color: #fff;
}
.topbar-logo {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.4px;
}
.topbar-search {
    flex: 1;
    display: flex;
    gap: 8px;
    align-items: center;
}
.topbar-search .input {
    background: #ffffff;
    color: #0f172a;
    border: none;
    box-shadow: 0 1px 0 rgba(0,0,0,0.08);
}
.topbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
body.theme-light .topbar .btn {
    background: #0f6fc7;
    border: none;
}
body.theme-light .topbar .btn-outline {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
}
body.theme-light {
    background: #f4f6fb;
    color: #0f172a;
}
body.theme-light .sidebar {
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
}
body.theme-light .content {
    background: #f4f7fb;
}
body.theme-light .details {
    background: #ffffff;
    border-left: 1px solid #e2e8f0;
}
body.theme-light .card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
}
body.theme-light .btn {
    background: #168de2;
}
body.theme-light .btn-outline {
    border: 1px solid #cbd5e1;
    color: #0f172a;
}
body.theme-light .input,
body.theme-light .textarea,
body.theme-light select {
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #d0d7e2;
}
body.theme-light .muted { color: #64748b; }
body.theme-light .nav-link.active { background: #e6eef9; }
body.theme-light .toolbar-search {
    background: #ffffff;
    border: 1px solid #dbe4f0;
}
@media (max-width: 1100px) {
    .app { grid-template-columns: 220px 1fr; }
    .details { display: none; }
}
@media (max-width: 800px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { border-right: none; border-bottom: 1px solid #2a3140; }
}

.title-sm {
    font-size: 16px;
    margin: 0 0 8px;
    font-weight: 600;
}
.btn {
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn:hover {
    background: #1d4ed8;
}
.btn-outline:hover {
    border-color: #475569;
    color: #f8fafc;
}
.btn-small {
    padding: 6px 10px;
    font-size: 12px;
}
.btn-danger {
    border-color: #334155;
    color: #94a3b8;
}
.btn-danger:hover {
    border-color: #ef4444;
    color: #fecaca;
}
.input:focus,
.textarea:focus,
select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-actions {
    flex-wrap: wrap;
}
.account-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #2a3140;
    background: #151a23;
    flex-wrap: wrap;
}
.account-actions {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    max-width: 100%;
}
.account-label {
    min-width: 0;
    flex: 1 1 180px;
    word-break: break-word;
}
.inline-form {
    display: inline-block;
    margin: 0;
}
.btn-full {
    width: 100%;
    text-align: center;
}
body.theme-light .account-item {
    background: #ffffff;
    border: 1px solid #e2e8f0;
}
@media (max-width: 900px) {
    .topbar {
        flex-wrap: wrap;
    }
    .topbar-search {
        order: 3;
        width: 100%;
    }
    .topbar-search .input {
        width: 100%;
    }
}

.empty-state {
    text-align: center;
    padding: 24px;
    color: #94a3b8;
    border-style: dashed;
}
.message-card {
    display: grid;
    gap: 8px;
    padding: 12px 10px;
    border-radius: 0;
    background: transparent;
    border: 1px solid transparent;
    border-bottom: 1px solid #2a3140;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    grid-template-columns: 26px 1fr;
    align-items: start;
}
.message-card:hover {
    background: #1b2029;
    border-color: #2a3140;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
}
.message-card.is-unread {
    background: rgba(37, 99, 235, 0.08);
    border-color: #2b3d5e;
    border-radius: 10px;
}
.unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3b82f6;
    margin-top: 0;
    flex: 0 0 auto;
}
.message-card.is-unread .message-subject {
    font-weight: 700;
}
.message-link {
    display: block;
    color: inherit;
    text-decoration: none;
}
.message-select {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 2px;
}
.message-select input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}
.message-main {
    display: grid;
    gap: 8px;
}
.message-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.message-subject {
    font-size: 15px;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.message-date {
    font-size: 12px;
    color: #94a3b8;
    white-space: nowrap;
}
.message-from {
    font-size: 13px;
    color: #cbd5e1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.message-actions {
    flex-wrap: nowrap;
    gap: 8px;
    justify-content: flex-end;
}
.message-card .message-actions {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
}
.message-actions .btn {
    padding: 6px 10px;
    font-size: 12px;
}
.message-card:hover .message-actions {
    opacity: 1;
    pointer-events: auto;
}
.message-card .tag {
    margin-top: 6px;
    width: fit-content;
}
.tag-attach {
    background: #1f2937;
    color: #cbd5f5;
}
body.theme-light .message-card {
    background: transparent;
    border: 1px solid transparent;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: none;
}
body.theme-light .message-select input {
    accent-color: #2563eb;
}

.bulk-form {
    display: grid;
    gap: 10px;
}
.bulk-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.bulk-select {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #94a3b8;
}
.bulk-actions {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}
body.theme-light .message-card:hover {
    background: #f8fafc;
    border-color: #dbe4f0;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    border-radius: 10px;
}
body.theme-light .message-card.is-unread {
    background: #eef2ff;
    border-color: #c7d2fe;
    border-radius: 10px;
}
body.theme-light .message-subject {
    color: #0f172a;
}
body.theme-light .message-from {
    color: #475569;
}
body.theme-light .message-date {
    color: #64748b;
}
body.theme-light .unread-dot {
    background: #2563eb;
}

@media (max-width: 900px) {
    .message-card .message-actions {
        opacity: 1;
        pointer-events: auto;
        justify-content: flex-start;
    }
}
.details .message-details {
    display: grid;
    gap: 12px;
}
.message-header {
    display: grid;
    gap: 6px;
}
.message-meta {
    display: grid;
    gap: 2px;
}
.message-body {
    line-height: 1.5;
    font-size: 14px;
}
.divider {
    height: 1px;
    background: #2a3140;
}
.attachment-list {
    display: grid;
    gap: 8px;
}
.attachment-card {
    padding: 10px 12px;
    border-radius: 8px;
}
.modal-actions {
    flex-wrap: wrap;
    gap: 8px;
}
.field .muted {
    font-size: 12px;
}
body.app-page .app {
    grid-template-columns: 240px 1fr;
}
.details {
    display: none;
}
.modal-message {
    max-width: 760px;
}
.message-open #message-modal {
    display: flex;
}
.quoted-preview {
    margin-top: 6px;
}
.quoted-preview summary {
    cursor: pointer;
    color: #9ca3af;
}
.quoted-preview pre {
    white-space: pre-wrap;
    background: #111827;
    padding: 10px;
    border-radius: 8px;
    margin-top: 6px;
    color: #cbd5e1;
    font-size: 12px;
}
body.theme-light .quoted-preview pre {
    background: #f3f4f6;
    color: #1f2937;
}
body.theme-light .message-date {
    color: #64748b;
}
body.theme-light .message-from {
    color: #475569;
}
body.theme-light .divider {
    background: #e2e8f0;
}
body.theme-light .tag-attach {
    background: #eef2ff;
    color: #4338ca;
}
body.theme-light .modal {
    background: rgba(15, 23, 42, 0.35);
}
body.theme-light .modal-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #0f172a;
}
body.theme-light .modal-close {
    color: #64748b;
}
body.theme-light .message-body {
    color: #0f172a;
}
body.theme-light .modal-actions .btn-outline {
    border-color: #cbd5e1;
    color: #0f172a;
}
body.theme-light .modal-message,
body.theme-light .modal-message .message-body,
body.theme-light .modal-message .html-body {
    color: #0f172a;
}
body.theme-light .modal-message .html-body *,
body.theme-light .modal-message .message-body * {
    color: inherit;
}
body.theme-light .modal-message a {
    color: #2563eb;
}
body.theme-light .modal-message pre,
body.theme-light .modal-message code {
    background: #f1f5f9;
    color: #0f172a;
}

@media (max-width: 700px) {
    body {
        font-size: 15px;
    }
    .topbar {
        padding: 10px 12px;
        gap: 10px;
    }
    .topbar-logo {
        font-size: 18px;
    }
    .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }
    .topbar-actions .btn,
    .topbar-actions .btn-outline {
        flex: 1 1 auto;
        text-align: center;
    }
    .topbar-search {
        width: 100%;
    }
    .app {
        grid-template-columns: 1fr;
    }
    .sidebar {
        padding: 12px;
        border-right: none;
        border-bottom: 1px solid #2a3140;
    }
    body.theme-light .sidebar {
        border-bottom: 1px solid #e2e8f0;
    }
    .sidebar .toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 4px;
    }
    .sidebar .toolbar .btn,
    .sidebar .toolbar .btn-outline {
        white-space: nowrap;
    }
    .sidebar > .list {
        display: flex;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 6px;
    }
    .sidebar > .list .nav-link {
        flex: 0 0 auto;
        border: 1px solid #2a3140;
        background: #151a23;
        white-space: nowrap;
    }
    body.theme-light .sidebar > .list .nav-link {
        border-color: #e2e8f0;
        background: #ffffff;
    }
    .content {
        padding: 12px;
    }
    .card,
    .message-card {
        padding: 12px;
    }
    .message-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .message-date {
        align-self: flex-start;
    }
    .modal {
        padding: 8px;
    }
    .modal-card {
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 16px;
        padding: 14px;
    }
    .modal-message {
        max-width: 100%;
    }
    .modal-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .input,
    .textarea,
    select,
    button {
        font-size: 15px;
    }
    .textarea {
        min-height: 160px;
    }
    body.login-page .login-card {
        padding: 20px 18px;
        border-radius: 12px;
    }
}

/* Force list-like message UI (override cache/old rules). */
body.app-page .content .message-card {
    background: transparent !important;
    border: 1px solid transparent !important;
    border-bottom: 1px solid #2a3140 !important;
    border-radius: 0 !important;
    padding: 12px 10px !important;
}
body.app-page .content .message-card:hover {
    background: #1b2029 !important;
    border-color: #2a3140 !important;
    border-radius: 10px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16) !important;
}
body.app-page.theme-light .content .message-card {
    background: transparent !important;
    border: 1px solid transparent !important;
    border-bottom: 1px solid #e2e8f0 !important;
    box-shadow: none !important;
}
body.app-page.theme-light .content .message-card:hover {
    background: #f8fafc !important;
    border-color: #dbe4f0 !important;
    border-radius: 10px !important;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08) !important;
}
body.app-page.theme-light .content .message-card.is-unread {
    background: #eef2ff !important;
    border-color: #c7d2fe !important;
}
body.app-page .content .message-card .message-actions {
    opacity: 0 !important;
    pointer-events: none !important;
}
body.app-page .content .message-card:hover .message-actions {
    opacity: 1 !important;
    pointer-events: auto !important;
}
@media (max-width: 900px) {
    body.app-page .content .message-card .message-actions {
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}
