:root {
    --wm-accent: #2563eb;
    --wm-sidebar: #0f172a;
    --wm-surface: #f8fafc;
    --wm-text: #0f172a;
    --wm-muted: #64748b;
    --wm-border: #e2e8f0;
    --wm-card: #ffffff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--wm-surface);
    color: var(--wm-text);
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: var(--wm-accent);
    text-decoration: none;
}

button, input, select, textarea {
    font: inherit;
}

/* ================= AUTH PAGES ================= */

.sm-auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 440px) 1fr;
    background: var(--wm-surface);
}

.sm-auth-hero {
    background: var(--wm-sidebar);
    color: #fff;
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sm-auth-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sm-monogram {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--wm-accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.sm-brand-logo {
    max-width: 140px;
    max-height: 44px;
    object-fit: contain;
}

.sm-auth-brand strong {
    display: block;
    font-size: 18px;
    letter-spacing: -0.3px;
}

.sm-auth-brand small {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-top: 2px;
}

.sm-auth-copy h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.6px;
    margin: 0 0 12px;
    line-height: 1.25;
}

.sm-auth-copy p {
    color: #cbd5e1;
    font-size: 14px;
    margin: 0 0 24px;
}

.sm-auth-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sm-auth-pill {
    font-size: 11px;
    padding: 6px 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.09);
    color: #e2e8f0;
}

.sm-auth-main {
    display: grid;
    place-items: center;
    padding: 32px;
}

.sm-auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border: 1px solid var(--wm-border);
    border-radius: 14px;
    padding: 36px 32px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.sm-auth-card h2 {
    margin: 0 0 6px;
    font-size: 22px;
    letter-spacing: -0.4px;
}

.sm-auth-card .sm-sub {
    color: var(--wm-muted);
    font-size: 13px;
    margin: 0 0 24px;
}

.sm-switcher-links {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--wm-border);
    display: flex;
    justify-content: space-between;
    font-size: 12.5px;
}

/* ================= ADMIN SHELL ================= */

.sm-app-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
}

.sm-sidebar {
    background: var(--wm-sidebar);
    color: #cbd5e1;
    padding: 26px 16px 20px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sm-sidebar-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 10px 26px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 20px;
    color: #fff;
}

.sm-sidebar-head strong {
    display: block;
    font-size: 15.5px;
    color: #fff;
}

.sm-sidebar-head small {
    display: block;
    font-size: 10px;
    color: #94a3b8;
    letter-spacing: 1.1px;
    text-transform: uppercase;
}

.sm-nav-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.sm-nav-btn {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 11px 14px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #cbd5e1;
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.sm-nav-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
}

.sm-nav-btn.is-active {
    background: var(--wm-accent);
    color: #fff;
    font-weight: 600;
}

.sm-nav-badge {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
}

.sm-sidebar-foot {
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sm-main {
    padding: 30px 36px 48px;
    max-width: 1480px;
    width: 100%;
}

.sm-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 26px;
}

.sm-topbar h1 {
    margin: 0;
    font-size: 24px;
    letter-spacing: -0.5px;
}

.sm-topbar p {
    margin: 4px 0 0;
    color: var(--wm-muted);
    font-size: 13px;
}

/* ================= CARDS, FORMS & TABLES ================= */

.sm-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.sm-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 22px;
}

.sm-stat-card {
    background: #fff;
    border: 1px solid var(--wm-border);
    border-radius: 12px;
    padding: 20px;
}

.sm-stat-label {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--wm-muted);
}

.sm-stat-val {
    font-size: 28px;
    font-weight: 700;
    margin: 8px 0 6px;
    letter-spacing: -0.7px;
}

.sm-stat-meta {
    font-size: 12px;
    color: var(--wm-muted);
}

.sm-card {
    background: #fff;
    border: 1px solid var(--wm-border);
    border-radius: 12px;
    margin-bottom: 22px;
    overflow: hidden;
}

.sm-card-head {
    padding: 18px 24px;
    border-bottom: 1px solid var(--wm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.sm-card-head h2 {
    margin: 0;
    font-size: 15.5px;
    font-weight: 650;
}

.sm-card-body {
    padding: 24px;
}

.sm-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.sm-field {
    margin-bottom: 16px;
}

.sm-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
}

.sm-input, .sm-select, .sm-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #0f172a;
    font-size: 13.5px;
}

.sm-input:focus, .sm-select:focus, .sm-textarea:focus {
    outline: none;
    border-color: var(--wm-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.sm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 15px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: opacity 0.15s, background 0.15s;
}

.sm-btn-primary {
    background: var(--wm-accent);
    color: #fff;
}

.sm-btn-primary:hover {
    opacity: 0.92;
}

.sm-btn-secondary {
    background: #f1f5f9;
    color: #334155;
    border-color: #cbd5e1;
}

.sm-btn-secondary:hover {
    background: #e2e8f0;
}

.sm-btn-danger {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.sm-btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}

.sm-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
}

.sm-badge.pass {
    background: #dcfce7;
    color: #15803d;
}

.sm-badge.warn {
    background: #fef3c7;
    color: #b45309;
}

.sm-badge.fail {
    background: #fee2e2;
    color: #b91c1c;
}

.sm-table-wrap {
    overflow-x: auto;
}

.sm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.sm-table th {
    text-align: left;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--wm-border);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--wm-muted);
}

.sm-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.sm-table tr:last-child td {
    border-bottom: 0;
}

.sm-code-box {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    background: #f8fafc;
    border: 1px solid var(--wm-border);
    padding: 8px 10px;
    border-radius: 6px;
    word-break: break-all;
}

.sm-alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 18px;
}

.sm-alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.sm-alert-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

/* ================= WEBMAIL 3-PANE CLIENT ================= */

.wm-shell {
    height: 100vh;
    display: grid;
    grid-template-columns: 240px 360px minmax(0, 1fr);
    overflow: hidden;
    background: var(--wm-surface);
}

.wm-shell.density-compact .wm-msg-item {
    padding: 10px 14px;
}

.wm-list-pane {
    background: #fff;
    border-right: 1px solid var(--wm-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
}

.wm-list-header {
    padding: 16px;
    border-bottom: 1px solid var(--wm-border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wm-search-row {
    display: flex;
    gap: 8px;
}

.wm-msg-list {
    flex: 1;
    overflow-y: auto;
}

.wm-msg-item {
    padding: 15px 16px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.12s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wm-msg-item:hover {
    background: #f8fafc;
}

.wm-msg-item.is-selected {
    background: #eff6ff;
    border-left: 3px solid var(--wm-accent);
}

.wm-msg-item.is-unread .wm-msg-sender,
.wm-msg-item.is-unread .wm-msg-subject {
    font-weight: 700;
    color: #0f172a;
}

.wm-msg-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.wm-msg-sender {
    font-size: 13.5px;
    font-weight: 500;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wm-msg-time {
    font-size: 11px;
    color: var(--wm-muted);
    white-space: nowrap;
}

.wm-msg-subject {
    font-size: 13px;
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wm-msg-preview {
    font-size: 12px;
    color: var(--wm-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wm-read-pane {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--wm-surface);
    min-width: 0;
}

.wm-read-toolbar {
    padding: 14px 24px;
    background: #fff;
    border-bottom: 1px solid var(--wm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.wm-read-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.wm-message-card {
    background: #fff;
    border: 1px solid var(--wm-border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
}

.wm-iframe {
    width: 100%;
    min-height: 420px;
    border: 0;
    background: #fff;
}

/* ================= MODAL ================= */

.sm-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: grid;
    place-items: center;
    z-index: 100;
    padding: 20px;
}

.sm-modal-backdrop[hidden] {
    display: none !important;
}

.sm-modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 720px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
    overflow: hidden;
}

.sm-modal-head {
    padding: 16px 22px;
    border-bottom: 1px solid var(--wm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sm-modal-head h3 {
    margin: 0;
    font-size: 16px;
}

.sm-modal-body {
    padding: 22px;
    overflow-y: auto;
    flex: 1;
}

.sm-modal-foot {
    padding: 14px 22px;
    border-top: 1px solid var(--wm-border);
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.wm-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
}

.wm-editor-area {
    min-height: 220px;
    max-height: 340px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 0 0 8px 8px;
    background: #fff;
}

.wm-editor-area:focus {
    outline: none;
    border-color: var(--wm-accent);
}

@media (max-width: 1024px) {
    .sm-auth-shell {
        grid-template-columns: 1fr;
    }
    .sm-auth-hero {
        display: none;
    }
    .sm-app-layout {
        grid-template-columns: 1fr;
    }
    .sm-sidebar {
        height: auto;
        position: static;
    }
    .sm-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .wm-shell {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }
    .wm-list-pane, .wm-read-pane {
        height: auto;
    }
}
