:root {
    --bg-body: #f4f7f9;
    --bg-sidebar: #ffffff;
    --accent: #4a90e2;
    --accent-soft: #eef5ff;
    --accent-hover: #357abd;
    --accent-rgb: 74, 144, 226;
    --text-main: #2c3e50;
    --text-muted: #7f8c8d;
    --border-color: #e1e4e8;
    --card-shadow: 0 10px 30px rgba(0,0,0,0.06);
    --radius: 12px;
    --radius-lg: 22px;
    --radius-xl: 28px;
    --panel-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
    --font-ui: 'Manrope', 'Segoe UI', sans-serif;
    --font-body: 'Source Sans 3', 'Segoe UI', sans-serif;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
    overscroll-behavior: none;
}

body {
    font-family: var(--font-body);
    background: radial-gradient(circle at top left, #fbfdff 0%, #f1f6fb 34%, #eaf1f7 100%);
    color: var(--text-main);
    overflow: hidden;
    min-height: 100vh;
    min-height: 100dvh;
}

html.is-pwa body {
    min-height: 100dvh;
}

.ms-icon { font-family: 'Material Symbols Rounded'; font-weight: normal; font-style: normal; font-size: 20px; display: inline-block; line-height: 1; vertical-align: middle; cursor: pointer; user-select: none; }
h1, h2, h3, h4, h5, h6, .btn-compose, .nav-item, .toggle-btn, .form-label { font-family: var(--font-ui); letter-spacing: -0.01em; }

.auth-locked .app-container,
.auth-locked .modal-window { display: none; }
.is-authenticated .login-screen { display: none; }
.is-authenticated .app-container { display: grid; }

.login-screen {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        linear-gradient(90deg, rgba(244,247,249,0.94), rgba(244,247,249,0.72)),
        url("../images/login-background.png") center / cover no-repeat;
}
.login-card { width: min(420px, 100%); background: white; border: 1px solid rgba(0,0,0,0.03); border-radius: 18px; box-shadow: var(--card-shadow); padding: 34px; }
.login-brand {
    width: 78px;
    height: 78px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    background: transparent;
}
.login-brand { filter: drop-shadow(0 10px 18px rgba(var(--accent-rgb), 0.18)); }
.login-brand-mark {
    width: 78px;
    height: 78px;
    display: block;
    overflow: visible;
}
.login-card h1 { margin: 0 0 8px; font-size: 24px; }
.login-card p { margin: 0 0 26px; color: var(--text-muted); line-height: 1.5; font-size: 14px; }
#loginStatus { display: block; min-height: 20px; margin-top: 15px; color: var(--text-muted); font-size: 13px; }

.app-container { display: grid; grid-template-columns: 280px 1fr; gap: 18px; height: 100vh; height: 100dvh; min-height: 100dvh; padding: 18px; box-sizing: border-box; overflow: hidden; }
html.is-pwa .app-shell {
    min-height: 100dvh;
}
.runtime-status {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4000;
    max-width: min(92vw, 760px);
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(127, 29, 29, 0.96);
    color: white;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.24);
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
}
.runtime-status[data-tone="success"] {
    background: rgba(22, 101, 52, 0.96);
}
html.is-pwa .runtime-status {
    top: calc(16px + env(safe-area-inset-top));
}

.install-hint {
    position: fixed;
    left: 50%;
    top: 18px;
    transform: translateX(-50%);
    z-index: 3900;
    width: min(92vw, 520px);
    padding: 14px 16px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
}

html.is-pwa .install-hint {
    display: none !important;
}

.install-hint-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.install-hint-copy strong {
    font-family: var(--font-ui);
    font-size: 14px;
}

.install-hint-copy span {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.45;
}

.install-hint-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.install-hint-button {
    margin: 0;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    box-shadow: none;
}

/* --- SIDEBAR --- */
.sidebar { background: rgba(255,255,255,0.96); border: 1px solid rgba(225, 228, 232, 0.9); border-radius: var(--radius-xl); display: flex; flex-direction: column; padding: 22px 18px; overflow-y: auto; z-index: 100; contain: layout style; will-change: scroll-position; box-shadow: var(--panel-shadow); }
.btn-compose { background: var(--accent); color: white; border: none; padding: 13px 16px; border-radius: 18px; font-weight: 700; cursor: pointer; margin-bottom: 25px; box-shadow: 0 8px 18px rgba(var(--accent-rgb), 0.18); display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 14px; transition: 0.2s; }
.btn-compose:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-compose:disabled { cursor: wait; opacity: 0.72; transform: none; box-shadow: 0 8px 18px rgba(var(--accent-rgb), 0.18); }
.btn-compose.is-loading .compose-send-label::after { content: ' ...'; }
.compose-send-status { font-size: 13px; color: var(--text-muted); }
.btn-secondary { background: #e8eef5; color: var(--text-main); box-shadow: none; }
.btn-secondary:hover { background: #dde6ef; }

.nav-header { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin: 20px 0 10px 10px; display: flex; justify-content: space-between; align-items: center; }
.nav-header-actions { display: inline-flex; align-items: center; gap: 6px; }
.nav-header-actions .ms-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #6b7c8d;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.nav-header-actions .ms-icon:hover {
    background: #eef3f8;
    color: #314558;
}
.nav-item { padding: 11px 13px; border-radius: 14px; cursor: pointer; margin-bottom: 4px; display: flex; align-items: center; font-size: 14px; gap: 10px; transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease; color: var(--text-main); }
.nav-item:hover { background: #f4f8fc; box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.85); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.1); }
.nav-item .ms-icon {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef3f8;
    color: #5f7182;
    font-size: 18px;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.nav-item:hover .ms-icon {
    background: #e6edf5;
    color: #44576a;
}
.nav-item.active .ms-icon {
    background: rgba(var(--accent-rgb), 0.14);
    color: var(--accent);
}
.mail-primary-folders {
    margin: 0 0 10px;
}
.mail-primary-folder {
    width: 100%;
    box-sizing: border-box;
}
.nav-unread-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--accent-rgb), 0.12);
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
    letter-spacing: 0;
}
.nav-item.active .nav-unread-badge {
    background: rgba(var(--accent-rgb), 0.18);
}
.folder-section-label {
    margin: 14px 10px 8px;
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.folder-disabled {
    opacity: 0.72;
    cursor: default;
}
.folder-disabled:hover {
    background: transparent;
}
.folder-disabled .ms-icon {
    background: #f1f5f9;
    color: #94a3b8;
}
.folder-toggle,
.folder-toggle-spacer {
    width: 20px;
    min-width: 20px;
    height: 20px;
    margin-right: 2px;
    flex: 0 0 auto;
}
.folder-toggle {
    border: 0;
    padding: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: #7b8a99;
    cursor: pointer;
}
.folder-toggle:hover {
    background: #eef3f8;
    color: #44576a;
}
.folder-toggle .ms-icon {
    width: auto;
    min-width: 0;
    height: auto;
    background: transparent;
    color: inherit;
    font-size: 18px;
}
.folder-toggle-spacer {
    display: inline-block;
}
.folder-namespace-public,
.folder-namespace-shared {
    color: #526273;
}
.folder-loading {
    color: var(--text-muted);
    cursor: default;
}
.folder-loading:hover {
    background: transparent;
}
.mobile-folder-add { display: none; }
.mobile-menu-button,
.mobile-sidebar-backdrop,
.mobile-compose-fab { display: none; }

/* --- MAIN VIEWS --- */
.view-content { display: grid; grid-template-columns: 370px 1fr; gap: 18px; height: 100%; overflow: hidden; min-height: 0; }
.column-list { background: rgba(255,255,255,0.97); border: 1px solid rgba(225, 228, 232, 0.92); border-radius: var(--radius-xl); display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; box-shadow: var(--panel-shadow); }
.column-detail { background: rgba(252,253,254,0.97); border: 1px solid rgba(225, 228, 232, 0.92); border-radius: var(--radius-xl); display: flex; flex-direction: column; height: 100%; overflow: hidden; min-height: 0; box-shadow: var(--panel-shadow); }

.header-section { padding: 26px 26px 22px; border-bottom: 1px solid rgba(226, 232, 240, 0.8); flex-shrink: 0; background: rgba(255,255,255,0.9); }
.mobile-toolbar-shell { margin-top: 0; }
.search-bar { width: 100%; padding: 12px 16px; border-radius: 16px; border: 1px solid rgba(148, 163, 184, 0.22); background: #ffffff; outline: none; margin-top: 15px; box-sizing: border-box; box-shadow: inset 0 1px 0 rgba(255,255,255,0.8); }
.search-bar:focus {
    border-color: rgba(var(--accent-rgb), 0.28);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.85), 0 0 0 4px rgba(var(--accent-rgb), 0.08);
}
.settings-anchor { position: relative; top: -18px; }
.settings-subsection { margin: 18px 0 10px; padding: 14px 16px; border: 1px solid var(--border-color); border-radius: 14px; background: #f8fafc; }
.settings-subsection-title { font-weight: 700; font-size: 15px; }
.settings-subsection-text { font-size: 12px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }
.settings-theme-panel { margin: 0 0 16px; padding: 18px; border: 1px solid var(--border-color); border-radius: 16px; background: white; }
.settings-theme-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.settings-inline-status { min-height: 20px; color: var(--text-muted); font-size: 12px; text-align: right; }
.theme-palette-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 96px)); gap: 14px; }
.theme-palette-card { border: 0; padding: 0; background: transparent; cursor: pointer; transition: transform 0.18s ease; text-align: center; }
.theme-palette-card:hover { transform: translateY(-1px); }
.theme-palette-card.active .theme-palette-swatch { box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18); border-color: var(--accent); }
.theme-palette-swatch { width: 64px; height: 64px; margin: 0 auto 8px; border-radius: 14px; border: 1px solid rgba(15, 23, 42, 0.1); background: #e5e7eb; }
.theme-palette-name { font-family: var(--font-ui); font-size: 13px; font-weight: 700; color: var(--text-main); }

.rich-editor { border: 1px solid var(--border-color); border-radius: 14px; background: white; overflow: hidden; }
.rich-editor-topbar,
.rich-editor-toolbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border-bottom: 1px solid #edf2f7; background: #fbfdff; }
.rich-editor-topbar { align-items: center; justify-content: space-between; }
.rich-editor-mode-switch,
.rich-editor-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rich-editor-select { width: auto; min-width: 120px; margin: 0; }
.rich-editor-select-size { min-width: 98px; }
.rich-editor-color { width: 40px; height: 36px; padding: 0; border: 1px solid var(--border-color); border-radius: 10px; background: white; }
.rich-editor-surface,
.rich-editor-source { min-height: 220px; border: 0; border-radius: 0; margin: 0; box-sizing: border-box; }
.rich-editor-surface,
.rich-editor-surface.form-input {
    padding: 22px 30px 22px 32px;
    overflow-y: auto;
    background: linear-gradient(180deg, #ffffff, #fcfdff);
    box-shadow: inset 1px 0 0 rgba(226, 232, 240, 0.9);
    border-bottom: 0;
}
.compose-surface { min-height: 220px; }
.compose-surface > :first-child { margin-top: 0; }
.compose-surface > :last-child { margin-bottom: 0; }
.compose-surface .mail-reply-quote {
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid #e6edf3;
}
.compose-surface .mail-reply-quote-meta {
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-muted);
}
.compose-surface .mail-reply-quote blockquote {
    margin: 0;
    padding: 12px 14px;
    border-left: 3px solid #dbe5f0;
    background: #f8fbfd;
    color: #526273;
    border-radius: 0 12px 12px 0;
    font-size: 13px;
    line-height: 1.55;
    max-height: 220px;
    overflow: auto;
}
.compose-surface .mail-reply-quote blockquote > :first-child { margin-top: 0; }
.compose-surface .mail-reply-quote blockquote > :last-child { margin-bottom: 0; }
.compose-surface .mail-reply-quote blockquote p,
.compose-surface .mail-reply-quote blockquote div,
.compose-surface .mail-reply-quote blockquote table {
    margin-top: 0;
    margin-bottom: 8px;
}
.compose-surface .mail-reply-quote img,
.compose-surface .mail-reply-quote table {
    max-width: 100%;
}
.rich-editor-surface:focus { outline: none; }
.rich-editor-surface img { max-width: 100%; height: auto; cursor: grab; }
.rich-editor-surface img.is-selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.rich-editor-surface img.is-dragging { opacity: 0.72; cursor: grabbing; }
.compose-editor { margin-top: 10px; }
.compose-editor .compose-editor-shell { border-bottom: 1px solid #edf2f7; background: linear-gradient(180deg, #ffffff, #f8fbfd); }
.compose-editor-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px 12px;
}
.compose-editor-mode-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}
.compose-editor-hint {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}
.compose-editor-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}
.compose-editor-action {
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid #dbe5ee;
    border-radius: 12px;
    background: rgba(255,255,255,0.94);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #55687b;
    font-size: 12px;
    font-weight: 700;
}
.compose-editor-action:hover {
    background: white;
    border-color: rgba(var(--accent-rgb), 0.24);
    color: var(--accent);
}
.compose-editor-action .ms-icon {
    font-size: 18px;
}
.compose-editor-action-tools .editor-toolbar-toggle-label + .ms-icon {
    font-size: 20px;
}
.compose-editor-toolbar-wrap {
    padding: 0 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.compose-editor-panel-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.compose-editor-panel-tab {
    min-height: 34px;
    padding: 0 14px;
    border: 1px solid #dbe5ee;
    border-radius: 999px;
    background: rgba(255,255,255,0.94);
    color: #5f7182;
    font: inherit;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.18s ease;
}
.compose-editor-panel-tab.active {
    border-color: rgba(var(--accent-rgb), 0.28);
    background: var(--accent-soft);
    color: var(--accent);
}
.compose-editor .rich-editor-toolbar-compose {
    gap: 12px;
    align-items: stretch;
    padding: 0;
    border-bottom: 0;
    background: transparent;
}
.compose-editor .editor-panel { display: none; }
.compose-editor .editor-panel.active { display: flex; }
.compose-editor.toolbar-collapsed .compose-editor-toolbar-wrap { display: none; }
.signature-editor {
    margin-top: 10px;
    border-radius: 20px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}
.signature-editor .signature-editor-shell {
    background:
        radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.10), transparent 26%),
        linear-gradient(180deg, #ffffff, #f7fbfd);
}
.signature-editor .signature-editor-topbar {
    padding-bottom: 14px;
}
.signature-editor .signature-editor-toolbar-wrap {
    border-top: 1px solid rgba(226, 232, 240, 0.9);
}
.signature-editor .signature-surface,
.signature-editor .rich-editor-source {
    min-height: 260px;
}
.signature-editor-assets {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    min-width: min(100%, 420px);
}
.signature-editor-assets-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}
.signature-editor-action-btn {
    width: auto !important;
    min-width: 0 !important;
    padding: 0 12px !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    background: #f8fbfe !important;
    border: 1px solid #dbe7f1 !important;
}
.signature-editor-action-btn .ms-icon {
    font-size: 18px;
}
.signature-editor-inline-note {
    display: block;
    width: 100%;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
    white-space: normal;
    overflow-wrap: anywhere;
}
.signature-editor-inline-note code {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 6px;
    border-radius: 8px;
    background: #eff5fb;
    color: #35516b;
}
.signature-editor-helper-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}
.signature-editor-helper-card,
.signature-snippet-panel {
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,251,253,0.96));
    padding: 14px 16px;
}
.signature-editor-helper-title {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 6px;
}
.signature-editor-helper-copy {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-muted);
}
.signature-snippet-panel {
    margin-top: 12px;
}
.signature-snippet-field {
    margin-top: 8px;
    min-height: 88px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1.55;
    background: #f8fafc;
}
.editor-tool-divider {
    width: 1px;
    height: 24px;
    background: #dbe5ee;
    margin: 0 2px;
}
.rich-editor-toolbar-compose {
    gap: 10px;
    align-items: stretch;
    padding: 12px 14px;
    background: linear-gradient(180deg, #fcfdff, #f5f8fc);
}
.editor-tool-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid #e5edf4;
    border-radius: 12px;
    background: rgba(255,255,255,0.92);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.72);
}
.editor-tool-label {
    padding-right: 6px;
    margin-right: 2px;
    border-right: 1px solid #e6edf3;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
}
.editor-tool-group .toolbar-btn {
    min-height: 34px;
    width: 34px;
    min-width: 34px;
    padding: 0;
    justify-content: center;
    border-radius: 10px;
    background: #f8fbfe;
    border: 1px solid transparent;
    color: #5d7084;
}
.editor-tool-group .toolbar-btn:hover {
    background: white;
    border-color: #d8e4ef;
    color: var(--text-main);
}
.editor-color-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 34px;
    border-radius: 10px;
    background: #f8fbfe;
    border: 1px solid transparent;
    color: #5d7084;
    overflow: hidden;
    cursor: pointer;
}
.editor-color-chip:hover {
    background: white;
    border-color: #d8e4ef;
}
.editor-color-chip .ms-icon {
    pointer-events: none;
    font-size: 18px;
}
.editor-color-chip .rich-editor-color {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: 0;
}
.editor-image-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid #edf2f7;
    background: linear-gradient(180deg, #fdfefe, #f6f9fc);
}
.editor-image-size {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #e5edf4;
    border-radius: 12px;
    background: white;
    font-family: var(--font-ui);
    font-size: 12px;
    color: #5f7182;
}
.editor-image-offset {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #e5edf4;
    border-radius: 12px;
    background: white;
    font-family: var(--font-ui);
    font-size: 12px;
    color: #5f7182;
}
.editor-image-size input[type="range"] {
    width: 160px;
}
.editor-image-offset input[type="range"] {
    width: 140px;
}
.editor-image-size input[type="number"] {
    width: 72px;
    min-height: 34px;
    border: 1px solid #dbe5ee;
    border-radius: 10px;
    padding: 0 10px;
    font: inherit;
    color: var(--text-main);
    background: #fbfdff;
}
.editor-image-offset input[type="number"] {
    width: 72px;
    min-height: 34px;
    border: 1px solid #dbe5ee;
    border-radius: 10px;
    padding: 0 10px;
    font: inherit;
    color: var(--text-main);
    background: #fbfdff;
}
.editor-image-align {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid #e5edf4;
    border-radius: 12px;
    background: white;
}
.rich-editor-surface img.image-left {
    display: block;
    margin: 8px auto 8px 0;
}
.rich-editor-surface img.image-center {
    display: block;
    margin: 8px auto;
}
.rich-editor-surface img.image-right {
    display: block;
    margin: 8px 0 8px auto;
}
.rich-editor-surface img.image-inline {
    display: inline-block;
    margin: 0;
}

@media (max-width: 900px) {
    .compose-editor-topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .compose-editor-actions {
        justify-content: flex-start;
    }

    .compose-editor-panel-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .compose-editor .editor-panel.active {
        flex-wrap: wrap;
    }
}

.recipient-field-wrap { position: relative; }
.recipient-row { display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: center; gap: 10px; margin-bottom: 10px; }
.recipient-label { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.recipient-input { margin: 0; }
.recipient-field-actions { display: flex; gap: 8px; justify-content: flex-end; margin: -4px 0 10px; }
.recipient-suggestions { position: absolute; left: 56px; right: 0; top: 44px; z-index: 40; background: white; border: 1px solid var(--border-color); border-radius: 12px; box-shadow: var(--card-shadow); max-height: 240px; overflow-y: auto; }
.recipient-suggestion { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #f1f5f9; }
.recipient-suggestion:last-child { border-bottom: 0; }
.recipient-suggestion:hover,
.recipient-suggestion.active { background: var(--accent-soft); }
.recipient-suggestion-title { font-weight: 600; font-size: 13px; }
.recipient-suggestion-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* --- LISTS --- */
.scroll-list { overflow-y: auto; flex-grow: 1; min-height: 0; contain: layout style; will-change: scroll-position; }
.card-item { padding: 18px 34px 18px 20px; border: 1px solid transparent; border-left: 4px solid transparent; border-radius: 18px; cursor: pointer; transition: background-color 0.15s ease, border-left-color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease; position: relative; contain: content; margin: 10px 12px 0; background: rgba(255,255,255,0.82); }
.card-item.active { background: var(--accent-soft); border-left-color: var(--accent); border-color: rgba(var(--accent-rgb), 0.14); box-shadow: 0 6px 14px rgba(var(--accent-rgb), 0.06); }
.card-item:hover { border-color: rgba(226, 232, 240, 0.92); box-shadow: 0 6px 14px rgba(15, 23, 42, 0.04); }
.card-item.unread::after { content: ''; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 8px; height: 8px; background: var(--accent); border-radius: 50%; }
.admin-user-card {
    cursor: default;
    border-left-width: 0;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.98) 0%, #fbfdff 100%);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.04);
    margin-bottom: 12px;
}
.admin-user-card:last-child {
    margin-bottom: 0;
}
.admin-user-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
}
.admin-user-card-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}
.admin-user-avatar {
    width: 46px;
    height: 46px;
    min-width: 46px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.18), rgba(var(--accent-rgb), 0.08));
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.05em;
}
.admin-user-copy {
    flex: 1 1 auto;
    min-width: 0;
}
.admin-user-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.admin-user-name {
    display: block;
    font-size: 16px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.3;
}
.admin-user-email {
    margin-top: 5px;
    font-size: 13px;
    color: #51606e;
    overflow-wrap: anywhere;
}
.admin-user-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}
.admin-user-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.admin-user-badge.tone-role {
    background: #eef2ff;
    color: #4338ca;
}
.admin-user-badge.tone-active {
    background: #ecfdf3;
    color: #166534;
}
.admin-user-badge.tone-inactive {
    background: #fff1f2;
    color: #be123c;
}
.admin-user-badge.tone-passkey {
    background: #ecfeff;
    color: #155e75;
}
.admin-user-badge.tone-warning {
    background: #fff7ed;
    color: #9a3412;
}
.admin-user-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
}
.admin-user-actions {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    max-width: 360px;
}
.admin-user-action {
    margin: 0;
    padding: 8px 12px;
    min-height: 38px;
    box-shadow: none;
    font-size: 13px;
}
.admin-user-action.tone-open {
    background: #eff6ff;
    color: #1d4ed8;
}
.admin-user-action.tone-unlock {
    background: #ecfeff;
    color: #155e75;
}
.admin-user-action.tone-warn {
    background: #fff7ed;
    color: #9a3412;
}
.admin-user-action.tone-neutral {
    background: #f8fafc;
    color: var(--text-main);
}
.admin-user-action.tone-soft {
    background: #e2e8f0;
    color: var(--text-main);
}
.admin-user-action.tone-success {
    background: #ecfdf3;
    color: #166534;
}
.message-list-row { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.message-card-main { flex: 1 1 auto; min-width: 0; }
.message-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e7eef6;
    color: #4d6275;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    overflow: hidden;
    flex: 0 0 auto;
}
.message-avatar img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    display: block;
}
.message-avatar.has-logo {
    background: white;
    border: 1px solid rgba(15, 23, 42, 0.08);
}
.message-avatar.tone-sky { background: #e7f0fb; color: #315f8b; }
.message-avatar.tone-mint { background: #e7f7f1; color: #256a57; }
.message-avatar.tone-amber { background: #fff1df; color: #8a5c16; }
.message-avatar.tone-rose { background: #fdecef; color: #8f4655; }
.message-avatar.tone-indigo { background: #ecebff; color: #5048a4; }
.message-avatar.tone-slate { background: #edf1f5; color: #51606e; }
.message-card-top { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 6px; min-width: 0; }
.message-card-from { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-card-from-row { flex: 1 1 auto; min-width: 0; display: inline-flex; align-items: center; gap: 6px; }
.message-contact-action { opacity: 0; }
.card-item:hover .message-contact-action,
.card-item.active .message-contact-action { opacity: 1; }
.message-card-date { flex: 0 0 auto; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; font-size: 11px; color: var(--text-muted); }
.message-card-subject { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-card-preview { font-size: 12px; color: var(--text-muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- PREMIUM MAIL READER --- */
.detail-toolbar { padding: 14px 20px; background: rgba(255,255,255,0.96); border-bottom: 1px solid rgba(226, 232, 240, 0.85); display: flex; gap: 6px; align-items: center; min-height: 56px; }
.detail-toolbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; position: relative; }
.toolbar-btn { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text-muted); font: inherit; font-size: 13px; }
.toolbar-btn:hover { background: #f3f6f9; color: var(--text-main); }
.toolbar-btn.icon-only { width: 36px; min-width: 36px; padding: 0; justify-content: center; }
.toolbar-btn.icon-only .ms-icon { font-size: 20px; }
.toolbar-btn-danger { color: #dc2626; background: rgba(220, 38, 38, 0.08); }
.toolbar-btn-danger:hover { background: rgba(220, 38, 38, 0.14); color: #b91c1c; }
.spam-confirm-popover {
    position: absolute;
    right: 126px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid #d9e6dd;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    white-space: nowrap;
    z-index: 8;
}
.spam-confirm-popover::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    width: 10px;
    height: 10px;
    background: #ffffff;
    border-right: 1px solid #d9e6dd;
    border-top: 1px solid #d9e6dd;
    transform: translateY(-50%) rotate(45deg);
}
.spam-confirm-text {
    font-size: 12px;
    font-weight: 600;
    color: #35544a;
}
.spam-confirm-yes,
.spam-confirm-no {
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    border: 0;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.spam-confirm-yes {
    background: #16a34a;
    color: #fff;
}
.spam-confirm-yes:hover {
    background: #15803d;
}
.spam-confirm-no {
    background: #eef2f7;
    color: #475569;
}
.spam-confirm-no:hover {
    background: #e2e8f0;
}
.mobile-back-button { display: none; }
.mobile-back-button.icon-only { width: 36px; min-width: 36px; padding: 0; justify-content: center; }
.detail-toolbar-empty {
    justify-content: flex-start;
}
.message-placeholder-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    color: var(--text-muted);
    flex-direction: column;
    gap: 10px;
    padding: 24px;
    text-align: center;
}
.mail-scroll-area { padding: 28px 28px 34px; overflow-y: auto; flex-grow: 1; min-height: 0; background: #f5f8fb; contain: layout style; will-change: scroll-position; }
.mail-card-full { background: rgba(255,255,255,0.99); border-radius: 24px; box-shadow: 0 12px 24px rgba(15,23,42,0.05); max-width: 960px; margin: 0 auto; border: 1px solid rgba(15,23,42,0.06); overflow: hidden; }
.mail-header-full { padding: 30px 34px 20px; border-bottom: 1px solid #f1f4f7; }
.mail-subject { margin: 0 0 22px; font-size: 26px; line-height: 1.3; font-weight: 500; color: var(--text-main); overflow-wrap: anywhere; }
.mail-meta-row { display: flex; align-items: flex-start; gap: 14px; min-width: 0; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; }
.avatar img { width: 24px; height: 24px; object-fit: contain; display: block; }
.mail-meta-main { flex: 1 1 auto; min-width: 0; }
.mail-sender-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; min-width: 0; }
.mail-sender-main { min-width: 0; display: inline-flex; align-items: center; gap: 8px; }
.mail-sender { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--text-main); }
.mail-date { flex: 0 0 auto; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text-muted); text-align: right; }
.mail-recipient-line { margin-top: 3px; font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-contact-chip { display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
.mail-contact-chip-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-contact-action {
    width: 24px;
    height: 24px;
    min-width: 24px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.16s ease, color 0.16s ease;
}
.mail-contact-action:hover { background: #eef2f7; color: var(--accent); }
.mail-contact-action .ms-icon { font-size: 16px; line-height: 1; }
.mail-body { padding: 30px 34px 38px; line-height: 1.65; font-size: 15px; color: #1f2937; overflow-wrap: anywhere; }
.mail-body img { max-width: 100%; height: auto; }
.mail-body table { max-width: 100%; }
.attachment-bar { padding: 14px 34px; border-top: 1px solid #f1f4f7; display: flex; flex-wrap: wrap; gap: 8px; }
.attachment-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 8px 12px; background: #f8fafc; border: 1px solid var(--border-color); border-radius: 8px; font-size: 12px; text-decoration: none; color: var(--text-main); cursor: pointer; }
.attachment-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-reply-row { padding: 18px 34px 26px; border-top: 1px solid #f1f4f7; display: flex; flex-wrap: wrap; gap: 10px; }
.mail-reply-button { min-height: 40px; padding: 0 16px; border: 1px solid var(--border-color); border-radius: 999px; background: white; color: var(--text-main); display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.mail-reply-button:hover { background: #f8fafc; }

/* --- CALENDAR VIEW (MONTH & WEEK) --- */
#view-calendar { grid-template-columns: 1fr; background: white; overflow: auto; }
.calendar-container { height: 100%; display: flex; flex-direction: column; padding: 26px; min-height: 0; overflow: auto; background: rgba(255,255,255,0.28); border-radius: var(--radius-xl); }
.calendar-header-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; position: sticky; top: 0; z-index: 3; background: white; padding-bottom: 12px; }
.view-toggle { display: flex; background: #f0f2f5; padding: 4px; border-radius: 10px; gap: 5px; }
.toggle-btn { border: none; padding: 6px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-muted); background: transparent; transition: 0.2s; }
.toggle-btn.active { background: white; color: var(--accent); box-shadow: 0 2px 5px rgba(0,0,0,0.05); }

/* Grid Monthly */
.calendar-grid-month { display: grid; grid-template-columns: repeat(7, 1fr); flex-grow: 1; border-top: 1px solid var(--border-color); border-left: 1px solid var(--border-color); }
.cal-cell { min-height: 100px; padding: 10px; border-right: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); position: relative; }
.cal-cell.today { background: var(--accent-soft); }

/* Grid Weekly */
.calendar-grid-week {
    display: grid;
    grid-template-columns: 78px repeat(7, minmax(0, 1fr));
    grid-auto-rows: 72px;
    flex-grow: 1;
    min-height: 0;
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: white;
    scrollbar-width: thin;
    scrollbar-color: rgba(127, 140, 141, 0.5) transparent;
}
.week-header-corner,
.week-header-day {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fbfcfd;
    border-bottom: 1px solid var(--border-color);
}
.week-header-corner {
    border-right: 1px solid var(--border-color);
}
.week-header-day {
    padding: 10px 8px;
    border-right: 1px solid var(--border-color);
    text-align: center;
}
.week-header-day:last-child {
    border-right: none;
}
.week-header-dayname {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.week-header-date {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
}
.week-header-day.is-today .week-header-date {
    background: var(--accent);
    color: white;
}
.week-time-label {
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid #eef2f5;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background: #fbfcfd;
}
.week-slot {
    border-right: 1px solid #eef2f5;
    border-bottom: 1px solid #eef2f5;
    position: relative;
    padding: 6px;
    background:
        linear-gradient(to bottom, rgba(74, 144, 226, 0.06) 0, rgba(74, 144, 226, 0.06) 1px, transparent 1px, transparent 100%);
}
.week-slot:nth-child(8n) {
    border-right: none;
}
.week-slot:hover {
    background-color: #f8fbff;
}
.week-slot.is-today {
    background-color: #f9fcff;
}

.calendar-grid-week::-webkit-scrollbar,
.scroll-list::-webkit-scrollbar,
.mail-scroll-area::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.calendar-grid-week::-webkit-scrollbar-track,
.scroll-list::-webkit-scrollbar-track,
.mail-scroll-area::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.calendar-grid-week::-webkit-scrollbar-thumb,
.scroll-list::-webkit-scrollbar-thumb,
.mail-scroll-area::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(127, 140, 141, 0.35);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.calendar-grid-week::-webkit-scrollbar-thumb:hover,
.scroll-list::-webkit-scrollbar-thumb:hover,
.mail-scroll-area::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(127, 140, 141, 0.55);
    background-clip: padding-box;
}

.event-pill { background: var(--accent); color: white; padding: 4px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; margin: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.week-slot .event-pill {
    display: block;
    margin: 0;
    border-radius: 8px;
    padding: 7px 8px;
    font-size: 11px;
    line-height: 1.25;
    box-shadow: 0 4px 10px rgba(74, 144, 226, 0.18);
}

/* --- MODALS (MAIL & APPOINTMENT) --- */
.modal-window { position: fixed; right: 30px; bottom: 0; width: 550px; background: white; border-radius: 24px 24px 0 0; box-shadow: 0 -12px 30px rgba(15, 23, 42, 0.12); transition: transform 0.34s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.24s ease, visibility 0.24s ease; z-index: 1000; display: flex; flex-direction: column; transform: translateY(calc(100% + 28px)); opacity: 0; visibility: hidden; pointer-events: none; }
#mailModal { width: min(720px, calc(100vw - 32px)); }
#mailModal.maximized { width: calc(100vw - 24px); }
.modal-window.active { transform: translateY(0); opacity: 1; visibility: visible; pointer-events: auto; }
.modal-window.maximized { top: 0; left: 0; width: 100vw; height: 100vh; right: 0; bottom: 0 !important; border-radius: 0; }
.modal-window > form { display: flex; flex-direction: column; flex-grow: 1; min-height: 0; }
.modal-header { background: #1a1c23; color: white; padding: 15px 20px; border-radius: 15px 15px 0 0; display: flex; justify-content: space-between; align-items: center; }
.modal-header-actions { display: inline-flex; align-items: center; gap: 6px; }
.modal-header-btn { width: 34px; height: 34px; border: 0; border-radius: 10px; background: rgba(255,255,255,0.08); color: white; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: background-color 0.18s ease, transform 0.18s ease; }
.modal-header-btn:hover { background: rgba(255,255,255,0.16); transform: translateY(-1px); }
.modal-header-btn .ms-icon { cursor: inherit; }
.compose-header {
    background: var(--accent);
}
.modal-body { padding: 25px; flex-grow: 1; overflow-y: auto; }

#securityLogsModal {
    inset: 0;
    width: 100vw;
    height: 100vh;
    right: auto;
    bottom: auto;
    border-radius: 0;
    background: rgba(15, 23, 42, 0.28);
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    transform: none;
}

#securityLogsModal.active {
    transform: none;
}

#securityLogsModal .modal-content {
    width: min(1240px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 32px 90px rgba(15, 23, 42, 0.24);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#securityLogsModal .modal-header {
    border-radius: 24px 24px 0 0;
}

#securityLogsModal .modal-body {
    flex: 1 1 auto;
    min-height: 0;
}

#adminUserDetailModal {
    inset: 0;
    width: 100vw;
    height: 100vh;
    right: auto;
    bottom: auto;
    border-radius: 0;
    background: rgba(15, 23, 42, 0.28);
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    transform: none;
}

#adminUserDetailModal.active {
    transform: none;
}

.admin-user-detail-shell {
    width: min(980px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 32px 90px rgba(15, 23, 42, 0.24);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.admin-user-detail-header {
    border-radius: 24px 24px 0 0;
    background: linear-gradient(135deg, #334155 0%, #1f2937 100%);
}

.admin-user-detail-content {
    display: grid;
    gap: 18px;
}

.admin-user-detail-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-detail-hero {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 18px;
    align-items: center;
    padding: 22px 24px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 22px;
    background:
        radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.12), transparent 34%),
        linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.admin-detail-avatar {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.18), rgba(var(--accent-rgb), 0.08));
    color: var(--accent);
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.05em;
}

.admin-detail-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.admin-detail-subtitle {
    margin-top: 6px;
    color: #51606e;
    font-size: 14px;
}

.admin-detail-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.admin-detail-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.95fr;
    gap: 18px;
}

.admin-detail-card {
    margin: 0;
    padding: 22px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
}

.admin-detail-card-title {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 800;
    margin-bottom: 14px;
}

.admin-detail-list {
    display: grid;
    gap: 10px;
    font-size: 14px;
}

.admin-detail-list strong {
    color: var(--text-main);
}

.admin-security-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.admin-security-stat {
    padding: 14px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.admin-security-stat-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.admin-security-stat-value {
    margin-top: 8px;
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
}

.settings-security-shell {
    display: grid;
    gap: 18px;
}

.settings-security-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    padding: 22px 24px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 22px;
    background:
        radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.12), transparent 34%),
        linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.settings-security-title {
    margin: 0;
    font-size: 24px;
    color: var(--text-main);
}

.settings-security-copy {
    margin: 8px 0 0;
    max-width: 720px;
    font-size: 14px;
    color: #51606e;
    line-height: 1.6;
}

.settings-security-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.settings-security-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 18px;
}

.settings-security-switch {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: center;
    margin-top: 8px;
    padding: 16px 18px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    margin-bottom: 16px;
    background: #fbfdff;
}

.settings-security-switch-title {
    font-weight: 700;
    font-size: 15px;
}

.settings-security-switch-copy {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.settings-security-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 700;
}

.settings-backup-box {
    margin-top: 16px;
    padding: 16px;
    border: 1px dashed var(--border-color);
    border-radius: 14px;
    background: #f8fafc;
}

#backupCodesPanel > div:first-child {
    margin-top: 8px;
}

.passkey-list {
    display: grid;
    gap: 12px;
}

.passkey-card {
    padding: 18px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 18px;
    background: linear-gradient(180deg, #fff 0%, #fbfdff 100%);
}

.passkey-card-top {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}

.passkey-card-name {
    font-weight: 800;
    font-size: 15px;
    color: var(--text-main);
}

.passkey-card-meta {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

.passkey-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; }
.form-input { width: 100%; border: none; border-bottom: 1px solid #e6edf3; padding: 12px 0; outline: none; font-family: var(--font-body); font-size: 16px; transition: 0.2s; box-sizing: border-box; background: transparent; color: var(--text-main); }
.form-input:focus { border-bottom-color: var(--accent); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

.compose-window {
    right: 24px;
    bottom: 0;
    width: min(720px, calc(100vw - 32px));
    height: min(78vh, 660px);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.24);
    overflow: hidden;
    z-index: 1300;
}

.compose-window.active {
    transform: translateY(0);
}

.compose-window.maximized {
    width: calc(100vw - 24px);
    height: calc(100vh - 24px);
    top: 12px;
    right: 12px;
    left: 12px;
    bottom: 12px !important;
    border-radius: 16px;
}

.compose-window.is-minimized {
    width: min(340px, calc(100vw - 24px));
    height: auto;
    min-height: 0;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.22);
}

.compose-window.is-minimized .compose-form {
    display: none;
}

.compose-header {
    min-height: 42px;
    padding: 0 8px 0 14px;
    border-radius: 16px 16px 0 0;
    background: var(--accent);
}

.compose-window.maximized .compose-header {
    border-radius: 16px 16px 0 0;
}

.compose-window.is-minimized .compose-header {
    border-radius: 14px 14px 0 0;
}

.compose-header-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 10px 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    text-align: left;
    font: inherit;
}

.compose-window-title {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
}

.compose-window-meta {
    font-size: 11px;
    color: rgba(255,255,255,0.62);
}

.compose-form {
    background: #fff;
}

.compose-body {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
    background: #fff;
}

.compose-fields {
    flex: 0 0 auto;
    border-bottom: 1px solid #eef2f6;
}

.compose-recipient-wrap {
    position: relative;
}

.compose-recipient-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 0 16px;
    min-height: 42px;
    border-bottom: 1px solid #eef2f6;
}

.compose-recipient-row.hidden {
    display: none;
}

.compose-recipient-label {
    font-size: 13px;
    font-weight: 500;
    color: #5f6368;
}

.compose-recipient-input-shell {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.compose-line-input {
    min-height: 42px;
    padding: 0;
    border-bottom: 0;
    font-size: 14px;
    line-height: 1.4;
}

.compose-line-input::placeholder {
    color: #80868b;
}

.compose-line-input:focus {
    border-bottom: 0;
}

.compose-recipient-actions {
    margin: 0;
    flex: 0 0 auto;
    gap: 6px;
}

.compose-inline-toggle {
    min-height: 28px;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #5f6368;
}

.compose-inline-toggle:hover {
    background: #f1f3f4;
    color: #202124;
}

.compose-contact-picker-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
}

.compose-contact-picker-toggle .ms-icon {
    font-size: 16px;
    line-height: 1;
}

.compose-subject-input {
    padding: 0 16px;
    min-height: 42px;
    border-bottom: 0;
}

.compose-recipient-wrap .recipient-suggestions {
    left: 58px;
    right: 16px;
    top: calc(100% - 4px);
    border-radius: 14px;
    box-shadow: 0 16px 38px rgba(15, 23, 42, 0.14);
}

.compose-contact-picker {
    position: absolute;
    left: 58px;
    right: 16px;
    top: calc(100% - 4px);
    z-index: 45;
    background: #fff;
    border: 1px solid #dde6ef;
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
    overflow: hidden;
}

.compose-contact-picker-head {
    padding: 10px 12px;
    border-bottom: 1px solid #eef2f6;
    background: #fbfcfe;
}

.compose-contact-picker-search {
    min-height: 38px;
    padding: 0;
    border-bottom: 0;
    font-size: 13px;
}

.compose-contact-picker-search:focus {
    border-bottom: 0;
}

.compose-contact-picker-list {
    max-height: 260px;
    overflow-y: auto;
}

.compose-contact-picker-item {
    width: 100%;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #f2f5f8;
    background: #fff;
    text-align: left;
    cursor: pointer;
}

.compose-contact-picker-item:last-child {
    border-bottom: 0;
}

.compose-contact-picker-item:hover {
    background: #f8fafc;
}

.compose-contact-picker-avatar {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: #e8eef6;
    color: #526273;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.compose-contact-picker-name {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compose-contact-picker-email {
    margin-top: 2px;
    font-size: 12px;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compose-contact-picker-empty {
    padding: 14px 12px;
    font-size: 12px;
    color: #64748b;
}

.compose-window .compose-editor {
    margin-top: 0;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.compose-window .compose-editor-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    border-bottom: 0;
    background: #fff;
}

.compose-window .compose-editor-topbar,
.compose-window .compose-editor-toolbar-wrap {
    display: none;
}

.compose-window .compose-editor-panel-tab {
    min-height: 30px;
    padding: 0 12px;
    font-size: 11px;
}

.compose-window .rich-editor-toolbar-compose {
    padding: 0;
    background: transparent;
}

.compose-window .editor-tool-group {
    padding: 8px;
    border-radius: 10px;
    box-shadow: none;
}

.compose-window .compose-surface {
    flex: 1 1 auto;
    min-height: 220px;
    padding: 18px 18px 12px;
    border-bottom: 0;
    box-shadow: none;
    background: #fff;
}

.compose-window .rich-editor-source {
    flex: 1 1 auto;
    min-height: 220px;
    padding: 18px;
    border-bottom: 0;
}

.compose-window .compose-surface .mail-reply-quote {
    margin-top: 16px;
    padding-top: 10px;
    border-top: 1px solid #eceff3;
}

.compose-window .compose-surface .mail-reply-quote-meta {
    margin-bottom: 8px;
    font-size: 12px;
    color: #6b7280;
}

.compose-window .compose-surface .mail-reply-quote blockquote {
    padding: 10px 12px;
    border-left: 2px solid #d0d7de;
    background: #f8f9fa;
    color: #59636e;
    border-radius: 0 10px 10px 0;
    max-height: 180px;
}

.compose-window .editor-image-tools {
    margin: 10px 14px 0;
    flex: 0 0 auto;
    border-radius: 12px;
}

.compose-footer {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 14px 12px;
    border-top: 1px solid #eef2f6;
    background: #fff;
}

.compose-footer-primary,
.compose-footer-tools,
.compose-footer-secondary {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.compose-send-button {
    margin: 0;
    min-height: 38px;
    padding: 0 20px;
    border-radius: 999px;
    box-shadow: 0 8px 20px rgba(var(--accent-rgb), 0.24);
}

.compose-send-status {
    white-space: nowrap;
}

.compose-compact-hint {
    display: none;
    font-size: 11px;
    color: #6b7280;
    line-height: 1.35;
}

.compose-footer-tools {
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    padding-bottom: 2px;
}

.compose-format-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding-right: 6px;
    margin-right: 2px;
    border-right: 1px solid #e8edf2;
    flex: 0 0 auto;
}

.compose-format-tool {
    width: 34px;
    min-width: 34px;
    height: 34px;
}

.compose-window.is-compact .compose-format-advanced,
.compose-window.is-compact .compose-action-advanced {
    display: none;
}

.compose-window.is-compact #composeFormattingButton,
.compose-window.is-compact #composeMoreButton {
    display: none;
}

.compose-window.is-compact .compose-compact-hint {
    display: inline-block;
}

.compose-toolbar-select {
    width: auto;
    min-width: 92px;
    height: 34px;
    padding: 0 28px 0 10px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #fff;
    color: #334155;
    font-size: 12px;
    line-height: 1;
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%);
    background-position: calc(100% - 14px) calc(50% - 2px), calc(100% - 9px) calc(50% - 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    border-bottom: 1px solid #e2e8f0;
    flex: 0 0 auto;
}

.compose-toolbar-font {
    min-width: 112px;
}

.compose-toolbar-size {
    min-width: 82px;
}

.compose-toolbar-select:focus {
    border-color: rgba(var(--accent-rgb), 0.4);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

.compose-color-tool {
    position: relative;
    overflow: hidden;
}

.compose-toolbar-color {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.compose-footer-tool,
.compose-discard-button {
    color: #5f6368;
    border-radius: 999px;
    flex: 0 0 auto;
}

.compose-footer-tool:hover,
.compose-discard-button:hover {
    background: #f1f3f4;
    color: #202124;
}

.compose-footer-tool.is-active,
.compose-format-tool.is-active {
    background: var(--accent-soft);
    color: var(--accent);
}

.compose-attach-label {
    position: relative;
    overflow: hidden;
}

.compose-footer-secondary {
    justify-content: flex-end;
}

.compose-attachment-list {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: #6b7280;
}

.compose-more-wrap {
    position: relative;
}

.compose-more-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    min-width: 190px;
    padding: 8px;
    border: 1px solid #e5eaf0;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 30;
}

.compose-more-item {
    min-height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #334155;
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.compose-more-item:hover {
    background: #f8fafc;
}

.compose-more-color {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    color: #334155;
    font-size: 13px;
}

.compose-toolbar-menu-select {
    width: 100%;
    min-width: 0;
    margin-bottom: 4px;
}

.compose-more-color input[type="color"] {
    position: static;
    opacity: 1;
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    padding: 0;
}

.compose-draft-overlay {
    position: absolute;
    inset: 0;
    z-index: 24;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.2);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.compose-draft-dialog {
    width: min(410px, 100%);
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 18px;
    background: rgba(255,255,255,0.98);
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
    overflow: hidden;
}

.compose-draft-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 10px;
}

.compose-draft-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

.compose-draft-close {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 999px;
    background: #eef2f7;
    color: #475569;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.compose-draft-close:hover {
    background: #e2e8f0;
}

.compose-draft-body {
    padding: 0 16px 12px;
}

.compose-draft-copy {
    margin: 0;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-main);
}

.compose-draft-status {
    display: block;
    margin-top: 14px;
    font-size: 13px;
    color: var(--text-muted);
}

.compose-draft-status[data-tone="error"] {
    color: #b42318;
}

.compose-draft-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 16px 16px;
    flex-wrap: wrap;
}

.settings-nav-list {
    padding: 10px 10px 14px;
}

.settings-nav-group + .settings-nav-group {
    margin-top: 14px;
}

.settings-nav-group-label {
    margin: 0 12px 6px;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6b7c8d;
}

.settings-nav-card {
    margin-top: 6px;
    padding: 14px 16px;
}

.settings-nav-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-nav-copy {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.settings-main-card {
    overflow: visible;
}

.settings-article-header {
    padding-bottom: 16px;
}

.settings-page-intro {
    max-width: 700px;
}

.mobile-settings-header {
    display: none;
}

.settings-form { padding: 30px 32px; }
.settings-form-subsection {
    padding-top: 0;
}
.settings-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.settings-section-header-tight {
    margin-bottom: 16px;
}

.settings-compact-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.settings-collapsible-card {
    margin: 4px 0 8px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.96);
    overflow: hidden;
}

.settings-collapsible-toggle {
    width: 100%;
    border: 0;
    background: transparent;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    text-align: left;
    cursor: pointer;
}

.settings-collapsible-kicker {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 4px;
}

.settings-collapsible-summary {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

.settings-collapsible-icon {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(var(--accent-rgb), 0.10);
    color: var(--accent);
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.settings-collapsible-card[data-expanded="true"] .settings-collapsible-icon {
    transform: rotate(180deg);
    background: rgba(var(--accent-rgb), 0.16);
}

.settings-collapsible-panel {
    padding: 0 20px 18px;
    border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.settings-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 2px;
}

.settings-actions-compact {
    padding-top: 6px;
}

.settings-status-output {
    display: block;
    margin-top: 10px;
    color: var(--text-muted);
    line-height: 1.45;
}

.settings-block-intro {
    margin-bottom: 12px;
}

.settings-inline-note {
    margin: -4px 0 14px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
}

.settings-admin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.settings-admin-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.settings-admin-options {
    display: flex;
    gap: 20px;
    align-items: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.settings-admin-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 14px;
    align-items: start;
}

.settings-mini-heading {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #334155;
}
.sidebar-footer {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid rgba(36, 52, 71, 0.08);
    display: flex;
    justify-content: center;
}

.brand-credit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: transform 0.18s ease, opacity 0.18s ease;
}
.brand-credit:hover {
    transform: translateY(-1px);
    opacity: 0.92;
}
.brand-credit img {
    width: 150px;
    max-width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

@media (max-width: 1024px) {
    .signature-editor-helper-grid {
        grid-template-columns: 1fr;
    }

    body, html {
        overflow: hidden;
        height: 100dvh;
        background: linear-gradient(180deg, #f4f8fc 0%, #edf3f8 100%);
    }

    .login-screen {
        min-height: 100dvh;
        padding: 18px;
    }

    .login-card {
        padding: 26px;
        border-radius: 14px;
    }

    .app-container {
        grid-template-columns: 1fr;
        gap: 0;
        height: 100dvh;
        padding: 0;
    }

    .mobile-menu-button {
        position: relative;
        z-index: 1;
        width: 54px;
        height: 54px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 0;
        padding: 0;
        border-right: 1px solid rgba(226, 232, 240, 0.9);
        border-radius: 18px 0 0 18px;
        background: rgba(var(--accent-rgb), 0.08);
        color: var(--accent);
        cursor: pointer;
        box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.08);
    }

    .mobile-menu-glyph {
        width: 16px;
        height: 12px;
        display: inline-flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .mobile-menu-glyph span {
        display: block;
        width: 16px;
        height: 2px;
        border-radius: 999px;
        background: currentColor;
    }

    body.mobile-detail-active .mobile-menu-button {
        display: none;
    }

    .mobile-sidebar-backdrop {
        position: fixed;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 1180;
        background: rgba(15, 23, 42, 0.32);
    }

    body.mobile-sidebar-open .mobile-sidebar-backdrop {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(86vw, 320px);
        height: 100dvh;
        padding: calc(18px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
        border: 1px solid rgba(226, 232, 240, 0.95);
        border-radius: 0 24px 24px 0;
        background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(246,250,253,0.96));
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        overflow-x: hidden;
        overflow-y: auto;
        box-shadow: 24px 0 44px rgba(15, 23, 42, 0.14);
        transform: translateX(-105%);
        transition: transform 0.24s ease;
        z-index: 1200;
        -webkit-overflow-scrolling: touch;
    }

    body.mobile-sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar .btn-compose {
        display: none;
    }

    .mobile-compose-fab {
        position: fixed;
        right: 18px;
        bottom: calc(18px + env(safe-area-inset-bottom));
        z-index: 1100;
        display: none;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: auto;
        min-width: 0;
        height: 56px;
        margin: 0;
        padding: 0 18px;
        border-radius: 999px;
        border: 0;
        background: var(--accent);
        color: white;
        font-family: var(--font-ui);
        font-weight: 700;
        white-space: nowrap;
        font-size: 13px;
        cursor: pointer;
        font-size: 14px;
        box-shadow: 0 12px 28px rgba(var(--accent-rgb), 0.26);
        opacity: 0;
        transform: translateY(10px);
        pointer-events: none;
    }

    body.is-authenticated.mobile-compose-visible .mobile-compose-fab {
        display: inline-flex;
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    body.mobile-detail-active .mobile-compose-fab {
        opacity: 0;
        transform: translateY(10px);
        pointer-events: none;
    }

    .nav-header {
        display: flex;
        margin-top: 18px;
    }

    .sidebar-footer {
        display: flex;
    }

    #folder-list,
    .sidebar > div[style*="margin-top: auto"] {
        display: block;
        margin: 0 !important;
    }

    .mobile-folder-add {
        display: none !important;
    }

    #folder-list .nav-item {
        min-width: 0;
        margin-bottom: 2px;
        padding-top: 9px;
        padding-bottom: 9px;
    }

    #folder-list {
        margin-top: 2px;
    }

    #folder-list .folder-tree-item {
        gap: 8px;
    }

    #folder-list .folder-tree-item .folder-toggle,
    #folder-list .folder-tree-item .folder-toggle-spacer {
        width: 18px;
        min-width: 18px;
        height: 18px;
        margin-right: 0;
    }

    #folder-list .folder-tree-item .folder-toggle .ms-icon {
        width: auto;
        height: auto;
        min-width: 0;
        font-size: 18px;
        background: transparent;
        color: inherit;
    }

    #folder-list .folder-tree-item .ms-icon[data-del="1"],
    #folder-list .folder-tree-item [data-del="1"].ms-icon {
        width: auto;
        height: auto;
        min-width: 0;
        background: transparent;
    }

    #folder-list .folder-tree-item > span[style*="display:flex"] {
        gap: 8px !important;
    }

    #folder-list .folder-section-label {
        margin: 12px 10px 6px;
    }

    #mailPrimaryFolders {
        margin: 0 0 8px;
    }

    .nav-item {
        min-width: 0;
        height: auto;
        min-height: 46px;
        margin-bottom: 4px;
        padding: 11px 12px;
        border-radius: 14px;
        flex-direction: row;
        justify-content: flex-start;
        gap: 10px;
        font-size: 14px;
        text-align: left;
    }

    .nav-item .ms-icon {
        width: 32px;
        height: 32px;
        min-width: 32px;
        font-size: 18px;
    }

    .view-content {
        grid-template-columns: 1fr;
        gap: 0;
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
        max-width: 100vw;
    }

    .header-section {
        padding: calc(16px + env(safe-area-inset-top)) 16px 14px;
        border-radius: 0;
        background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(247,250,253,0.9));
        border-bottom: 1px solid rgba(226, 232, 240, 0.9);
    }

    .mobile-toolbar-shell {
        display: grid;
        grid-template-columns: 54px minmax(0, 1fr);
        align-items: stretch;
        gap: 0;
        margin-top: 12px;
        border: 1px solid rgba(226, 232, 240, 0.95);
        border-radius: 20px;
        overflow: hidden;
        background: rgba(255,255,255,0.92);
        box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
    }

    .column-list,
    .column-detail {
        grid-column: 1;
        grid-row: 1;
        width: 100%;
        min-width: 0;
        border-right: 0;
        border-left: 0;
        border-radius: 0;
        box-shadow: none;
        background: transparent;
    }

    .scroll-list {
        padding: 8px 0 20px;
        background: linear-gradient(180deg, rgba(243,247,251,0.7), rgba(238,244,249,0.95));
        overflow-x: hidden;
    }

    #messageList,
    #contactList {
        padding: 0 10px calc(96px + env(safe-area-inset-bottom));
        box-sizing: border-box;
    }

    #view-mail .column-detail,
    #view-contacts .column-detail {
        display: none;
    }

    #view-mail.mobile-detail-open .column-list,
    #view-contacts.mobile-detail-open .column-list {
        display: none;
    }

    #view-mail.mobile-detail-open .column-detail,
    #view-contacts.mobile-detail-open .column-detail {
        display: flex;
    }

    .detail-toolbar {
        position: sticky;
        top: 0;
        z-index: 4;
        padding: calc(8px + env(safe-area-inset-top)) 12px 10px;
        gap: 8px;
        overflow-x: auto;
        background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(246,250,253,0.95));
        border-bottom: 1px solid rgba(226, 232, 240, 0.92);
    }

    .toolbar-btn {
        min-height: 42px;
        padding: 0 10px;
        border-radius: 12px;
        background: rgba(255,255,255,0.9);
        white-space: nowrap;
        font-size: 13px;
        flex-shrink: 0;
        box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.9);
    }

    .mobile-back-button {
        min-height: 42px;
        padding: 0 12px;
        border: 0;
        border-radius: 12px;
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: rgba(var(--accent-rgb), 0.12);
        color: var(--accent);
        font: inherit;
        font-weight: 700;
        flex-shrink: 0;
        box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.14);
    }

    .mobile-back-button.icon-only {
        width: 42px;
        min-width: 42px;
        padding: 0;
    }

    .detail-toolbar-actions {
        margin-left: auto;
    }

    .spam-confirm-popover {
        right: 0;
        top: calc(100% + 8px);
        transform: none;
    }

    .spam-confirm-popover::after {
        right: 18px;
        top: -6px;
        border-right: 0;
        border-top: 1px solid #d9e6dd;
        border-left: 1px solid #d9e6dd;
        transform: rotate(45deg);
    }

    .spam-confirm-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1290;
        background: rgba(15, 23, 42, 0.22);
    }

    .spam-confirm-popover.is-mobile-modal {
        position: fixed;
        left: 50%;
        right: auto;
        top: max(calc(24px + env(safe-area-inset-top)), 18vh);
        transform: translateX(-50%);
        width: min(280px, calc(100vw - 32px));
        max-width: calc(100vw - 32px);
        padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        white-space: normal;
        border-radius: 16px;
        z-index: 1300;
        box-sizing: border-box;
    }

    .spam-confirm-popover.is-mobile-modal::after {
        display: none;
    }

    .spam-confirm-popover.is-mobile-modal .spam-confirm-text {
        grid-column: 1 / -1;
        font-size: 14px;
        text-align: center;
    }

    .spam-confirm-popover.is-mobile-modal .spam-confirm-yes,
    .spam-confirm-popover.is-mobile-modal .spam-confirm-no {
        min-height: 40px;
    }

    .search-bar {
        margin-top: 0;
        min-height: 54px;
        padding: 0 18px;
        border: 0;
        border-radius: 0;
        background: transparent;
        color: var(--text-main);
        font-size: 15px;
        font-weight: 500;
    }

    .search-bar:focus {
        background: rgba(255, 255, 255, 0.9);
        box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.16);
    }

    .search-bar::placeholder {
        color: #7b8794;
    }

    .mail-scroll-area {
        padding: 12px 12px 24px;
        -webkit-overflow-scrolling: touch;
        background: linear-gradient(180deg, #f4f8fb, #eef4f8);
        max-height: 100dvh;
    }

    .mail-card-full {
        max-width: none;
        border-radius: 18px;
        box-shadow: 0 10px 26px rgba(15, 23, 42, 0.05);
        border: 1px solid rgba(226, 232, 240, 0.95);
    }

    .mail-header-full,
    .mail-body,
    .settings-form {
        padding: 20px;
    }

    .card-item {
        margin: 0 0 10px;
        border-radius: 18px;
        border-left-width: 0;
        border: 1px solid rgba(226, 232, 240, 0.92);
        background: rgba(255,255,255,0.94);
        box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
    }

    .card-item.active {
        border-left-width: 0;
        box-shadow: 0 10px 24px rgba(var(--accent-rgb), 0.08);
    }

    .settings-nav-list {
        padding: 8px 8px 14px;
    }

    .settings-nav-card {
        padding: 13px 14px;
    }

    .settings-compact-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .settings-collapsible-toggle,
    .settings-collapsible-panel {
        padding-left: 18px;
        padding-right: 18px;
    }

    .settings-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .settings-security-hero,
    .settings-security-grid,
    .admin-detail-grid,
    .admin-detail-hero {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .settings-security-switch {
        grid-template-columns: 1fr;
    }

    .settings-admin-grid {
        grid-template-columns: 1fr;
    }

    .admin-user-detail-shell {
        width: min(100vw - 24px, 980px);
        max-height: calc(100vh - 24px);
        border-radius: 18px;
    }

    .passkey-card-top,
    .admin-detail-hero {
        flex-direction: column;
    }

    .passkey-card-actions,
    .settings-security-actions,
    .admin-user-detail-footer {
        justify-content: flex-start;
    }

    .admin-user-card-top,
    .admin-user-heading {
        flex-direction: column;
    }

    .admin-user-badges,
    .admin-user-actions {
        justify-content: flex-start;
    }

    .admin-user-actions {
        max-width: none;
        width: 100%;
    }

    .admin-user-action {
        flex: 1 1 calc(50% - 8px);
        justify-content: center;
    }

    .mail-subject {
        font-size: 21px;
        margin-bottom: 18px;
    }

    .mail-sender-row {
        display: block;
    }

    .mail-date {
        display: block;
        max-width: none;
        text-align: left;
        margin-top: 4px;
    }

    .mail-body {
        font-size: 15px;
        line-height: 1.62;
    }

    .attachment-bar,
    .mail-reply-row {
        padding-left: 20px;
        padding-right: 20px;
    }

    .message-card-date {
        max-width: 82px;
    }

    #view-settings {
        display: block;
        overflow: auto;
        height: 100dvh;
        -webkit-overflow-scrolling: touch;
        background: linear-gradient(180deg, #f4f8fb, #eef4f8);
    }

    #view-settings.hidden {
        display: none !important;
    }

    #view-settings .column-list {
        display: none;
    }

    #view-settings .column-detail {
        display: block;
        height: auto;
        overflow: visible;
        background: transparent;
    }

    .mobile-settings-header {
        position: sticky;
        top: 0;
        z-index: 8;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
        background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(245,249,252,0.95));
        border-bottom: 1px solid rgba(226, 232, 240, 0.92);
    }

    .install-hint {
        top: calc(12px + env(safe-area-inset-top));
        width: calc(100vw - 24px);
        padding: 14px;
        align-items: stretch;
        flex-direction: column;
    }

    .install-hint-actions {
        width: 100%;
        justify-content: stretch;
    }

    .install-hint-button {
        flex: 1 1 0;
    }

    .mobile-settings-header .mobile-menu-button {
        flex: 0 0 auto;
        border-radius: 16px;
        border-right: 0;
        box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.1);
    }

    .mobile-settings-header-copy {
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .mobile-settings-header-kicker {
        font-family: var(--font-ui);
        font-size: 11px;
        font-weight: 800;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: #6b7c8d;
    }

    .mobile-settings-header-copy strong {
        font-family: var(--font-ui);
        font-size: 16px;
        color: var(--text-main);
        line-height: 1.2;
    }

    .settings-form div[style*="grid-template-columns"],
    .modal-body div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
    }

    .settings-form div[style*="justify-content:flex-end"],
    .settings-form div[style*="justify-content: flex-end"] {
        flex-direction: column;
        align-items: stretch;
    }

    .settings-form .btn-compose {
        width: 100%;
        min-height: 46px;
        margin: 0;
    }

    #view-calendar {
        height: 100dvh;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }

    .calendar-container {
        height: auto;
        min-height: 100%;
        padding: 14px;
        overflow: visible;
        background: linear-gradient(180deg, #f4f8fb, #eef4f8);
    }

    .calendar-header-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 12px;
        padding: calc(58px + env(safe-area-inset-top)) 0 12px;
    }

    .calendar-header-actions > div:first-child {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px !important;
    }

    #calendar-title {
        min-width: 140px !important;
        font-size: 18px !important;
    }

    .view-toggle,
    .toggle-btn {
        width: 100%;
    }

    .toggle-btn {
        min-height: 42px;
    }

    .calendar-grid-month {
        min-width: 680px;
        min-height: 560px;
        flex: 0 0 auto;
    }

    .cal-cell {
        min-height: 82px;
    }

    .calendar-grid-week {
        grid-template-columns: 62px repeat(7, minmax(116px, 1fr));
        min-width: 874px;
        max-height: calc(100dvh - 230px);
        flex: 0 0 auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-window {
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        max-width: none;
        height: 94dvh;
        border-radius: 16px 16px 0 0;
        transform: translateY(105%);
    }

    .modal-window.active {
        transform: translateY(0);
    }

    .modal-window.maximized {
        top: 0;
        left: 0;
        width: 100vw;
        height: 100dvh;
        right: 0;
        bottom: 0 !important;
        border-radius: 0;
    }

    .modal-header {
        border-radius: 16px 16px 0 0;
        min-height: 52px;
    }

    #securityLogsModal {
        padding: 0;
        align-items: stretch;
        justify-content: flex-end;
        background: rgba(15, 23, 42, 0.22);
    }

    #securityLogsModal .modal-content {
        width: 100%;
        max-width: none;
        max-height: 94dvh;
        border-radius: 16px 16px 0 0;
    }

    #securityLogsModal .modal-header {
        border-radius: 16px 16px 0 0;
    }

    .modal-window.maximized .modal-header {
        border-radius: 0;
    }

    .modal-body {
        padding: 18px;
        -webkit-overflow-scrolling: touch;
    }

    .compose-window {
        right: 12px;
        bottom: 0;
        width: min(96vw, 720px);
        height: min(82dvh, 640px);
    }

    .compose-window.maximized {
        inset: 8px !important;
        width: auto;
        height: auto;
        border-radius: 14px;
    }

    .compose-draft-overlay {
        align-items: flex-end;
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .compose-draft-dialog {
        width: 100%;
        max-width: 360px;
        border-radius: 20px;
    }

    .compose-draft-head {
        padding-top: 16px;
    }

    .compose-draft-actions {
        padding-bottom: 16px;
    }

    .compose-body {
        padding: 0;
    }

    .compose-footer {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .compose-footer-primary,
    .compose-footer-tools,
    .compose-footer-secondary {
        justify-content: flex-start;
    }

    .compose-format-group {
        border-right: 0;
        padding-right: 0;
        margin-right: 0;
    }


    .compose-attachment-list {
        max-width: none;
        flex: 1 1 auto;
    }

    .compose-window .compose-editor-topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .compose-window .compose-editor-actions {
        justify-content: flex-start;
    }

    .form-input {
        min-height: 44px;
        font-size: 16px;
    }

    #composeForm textarea[name="html"] {
        min-height: 38dvh;
    }
}

@media (max-width: 520px) {
    .compose-window {
        right: 8px;
        left: 8px;
        width: auto;
        height: min(84dvh, 640px);
    }

    .compose-window.is-minimized {
        left: 8px;
        right: 8px;
        width: auto;
    }

    .compose-recipient-row {
        grid-template-columns: 34px minmax(0, 1fr);
        gap: 10px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .compose-subject-input {
        padding-left: 12px;
        padding-right: 12px;
    }

    .compose-recipient-wrap .recipient-suggestions {
        left: 46px;
        right: 12px;
    }

    .compose-window .compose-editor-hint {
        display: none;
    }

    .mobile-compose-fab {
        width: 56px;
        height: 56px;
        padding: 0;
        border-radius: 18px;
    }

    .mobile-compose-fab .ms-icon {
        font-size: 22px;
    }

    .mobile-compose-fab .compose-label {
        display: none;
    }

    .header-section {
        padding-right: 18px;
    }

    .mobile-toolbar-shell {
        grid-template-columns: 50px minmax(0, 1fr);
    }

    .mobile-menu-button {
        width: 50px;
        height: 50px;
        border-radius: 16px 0 0 16px;
    }

    .search-bar {
        min-height: 50px;
        padding: 0 14px;
    }
}

.hidden { display: none !important; }
