/* ---------- База ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: #0f1115;
    color: #e6e8eb;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: #60a5fa; text-decoration: none; }
a:hover { text-decoration: underline; }
input, textarea, button { font-family: inherit; font-size: inherit; }

/* ---------- Логин ---------- */
.login-body {
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 50% 0%, #1a2130 0%, #0f1115 70%);
}
.login-card {
    background: #171a21;
    padding: 36px 32px;
    border-radius: 16px;
    width: 360px;
    display: flex; flex-direction: column; gap: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.04);
}
.login-card h1 {
    margin: 0 0 4px; font-size: 22px; letter-spacing: .5px; color: #fff;
    text-align: center;
}
.login-card h1::before {
    content: "✉"; display: block; font-size: 34px; margin-bottom: 8px;
    color: #3b82f6;
}
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: #8b93a1; text-transform: uppercase; letter-spacing: .5px; }
.login-card input {
    background: #0f1115; border: 1px solid #2a2f3a; color: #e6e8eb;
    padding: 12px 14px; border-radius: 10px; font-size: 15px;
    transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus {
    outline: 0; border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}
.login-card button {
    margin-top: 4px; background: linear-gradient(180deg, #3b82f6, #2563eb);
    color: white; border: 0; padding: 13px; border-radius: 10px;
    font-size: 15px; font-weight: 600; cursor: pointer;
    transition: transform .05s, filter .15s;
}
.login-card button:hover { filter: brightness(1.1); }
.login-card button:active { transform: scale(.98); }

/* ---------- Лэйаут ---------- */
.layout { display: grid; grid-template-columns: 260px 1fr; height: 100vh; }

.sidebar {
    background: #12151b;
    padding: 20px 12px;
    display: flex; flex-direction: column; gap: 4px;
    border-right: 1px solid #1e2330;
    overflow-y: auto;
}
.brand {
    font-weight: 700; padding: 6px 12px 18px; color: #fff;
    font-size: 17px; letter-spacing: .3px;
    display: flex; align-items: center; gap: 8px;
}
.brand::before { content: "✉"; color: #3b82f6; font-size: 20px; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar a {
    color: #c6ccd6; padding: 10px 14px;
    border-radius: 10px; font-size: 14px;
    display: flex; align-items: center; gap: 10px;
    transition: background .12s;
}
.sidebar a:hover { background: #1c2230; text-decoration: none; }
.sidebar a.active { background: linear-gradient(90deg, #1e3a8a, #1e40af); color: #fff; font-weight: 600; }
.sidebar a.folder::before { content: "📁"; font-size: 13px; }
.sidebar a.logout { margin-top: auto; color: #f87171; }
.sidebar a.logout::before { content: "⎋"; }

/* ---------- Контент ---------- */
.content { overflow-y: auto; padding: 18px 22px 60px; }

.topbar {
    display: flex; gap: 10px; margin-bottom: 18px;
    position: sticky; top: 0; background: #0f1115; padding: 6px 0;
    z-index: 5;
}
.search { flex: 1; display: flex; gap: 6px; }
.search input {
    flex: 1; background: #171a21; border: 1px solid #2a2f3a;
    color: #e6e8eb; padding: 10px 14px; border-radius: 10px;
    transition: border-color .15s;
}
.search input:focus { outline: 0; border-color: #3b82f6; }
.search button {
    background: #2a2f3a; color: #e6e8eb; border: 0;
    padding: 0 18px; border-radius: 10px; cursor: pointer;
    font-weight: 500;
}
.search button:hover { background: #353b48; }

.btn, .btn-primary, .btn-danger {
    border: 0; border-radius: 10px; padding: 10px 16px;
    cursor: pointer; font-size: 14px; text-decoration: none;
    color: #fff; font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
    transition: filter .15s;
}
.btn { background: #2a2f3a; color: #e6e8eb; }
.btn:hover { background: #353b48; text-decoration: none; }
.btn-primary { background: linear-gradient(180deg, #3b82f6, #2563eb); }
.btn-primary:hover { filter: brightness(1.1); text-decoration: none; }
.btn-danger { background: #b91c1c; }
.btn-danger:hover { filter: brightness(1.1); }

/* ---------- Список писем ---------- */
.maillist { list-style: none; margin: 0; padding: 0; }
.mailitem a {
    display: flex; gap: 14px; padding: 14px 12px;
    border-radius: 12px; color: inherit; text-decoration: none;
    border-bottom: 1px solid #1a1f29;
    transition: background .12s;
}
.mailitem a:hover { background: #171c25; text-decoration: none; }
.mailitem.unread a { background: #131924; }
.mailitem.unread .subject { font-weight: 700; color: #fff; }
.mailitem.unread .from { color: #fff; }

.avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px; flex: 0 0 44px;
    text-transform: uppercase;
}
.mailitem:nth-child(4n+2) .avatar { background: linear-gradient(135deg, #ef4444, #f97316); }
.mailitem:nth-child(4n+3) .avatar { background: linear-gradient(135deg, #10b981, #14b8a6); }
.mailitem:nth-child(4n+4) .avatar { background: linear-gradient(135deg, #8b5cf6, #ec4899); }

.meta { flex: 1; min-width: 0; }
.row1, .row2 { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.from { font-weight: 600; color: #dde2ea; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date { color: #7d8794; font-size: 12px; flex: 0 0 auto; }
.subject { color: #c6ccd6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.preview {
    color: #7d8794; font-size: 13px; margin-top: 4px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.star, .clip { margin-left: 6px; font-size: 13px; }
.star { color: #fbbf24; }
.clip { color: #7d8794; }
.empty { padding: 40px; color: #7d8794; text-align: center; font-size: 15px; }

/* ---------- Письмо ---------- */
.message { max-width: 900px; }
.message header h1 {
    margin: 0 0 14px; font-size: 22px; color: #fff; line-height: 1.3;
}
.headers {
    color: #a3a9b3; font-size: 13px; line-height: 1.7;
    background: #171a21; padding: 14px 16px; border-radius: 10px;
    border: 1px solid #1e2330;
}
.headers b { color: #c6ccd6; font-weight: 600; }
.actions { margin: 18px 0; display: flex; gap: 10px; flex-wrap: wrap; }

.attachments {
    margin: 16px 0; padding: 14px 16px; background: #171a21;
    border-radius: 10px; font-size: 13px; border: 1px solid #1e2330;
}
.attachments b { color: #c6ccd6; }
.attachments ul { margin: 8px 0 0; padding-left: 20px; }
.attachments a { color: #60a5fa; }
.size { color: #7d8794; margin-left: 6px; }

.body { margin-top: 20px; }
.body iframe {
    width: 100%; min-height: 550px; border: 0; background: #fff;
    border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,.3);
}
.body pre {
    white-space: pre-wrap; word-wrap: break-word;
    font-family: inherit; background: #171a21; padding: 18px;
    border-radius: 10px; color: #dde2ea;
}

/* ---------- Форма ---------- */
.compose { max-width: 760px; display: flex; flex-direction: column; gap: 14px; }
.compose h1 { margin: 0 0 4px; font-size: 20px; color: #fff; }
.compose label {
    display: flex; flex-direction: column; gap: 6px;
    font-size: 12px; color: #8b93a1;
    text-transform: uppercase; letter-spacing: .5px;
}
.compose input, .compose textarea {
    background: #171a21; border: 1px solid #2a2f3a; color: #e6e8eb;
    padding: 12px 14px; border-radius: 10px; font-size: 14px;
    font-family: inherit; transition: border-color .15s;
}
.compose input:focus, .compose textarea:focus {
    outline: 0; border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.compose textarea { resize: vertical; min-height: 220px; line-height: 1.6; }

.error {
    background: #7f1d1d; color: #fee2e2; padding: 12px 16px;
    border-radius: 10px; font-size: 13px; border: 1px solid #991b1b;
}

/* ---------- Скроллбар ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #0f1115; }
::-webkit-scrollbar-thumb { background: #2a2f3a; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #353b48; }

/* ---------- Мобильный ---------- */
@media (max-width: 720px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        flex-direction: row; overflow-x: auto; padding: 10px;
        border-right: 0; border-bottom: 1px solid #1e2330;
        gap: 6px;
    }
    .brand { padding: 6px 12px; font-size: 15px; }
    .sidebar nav { flex-direction: row; gap: 4px; }
    .sidebar a { white-space: nowrap; padding: 8px 12px; font-size: 13px; }
    .sidebar a.logout { margin-top: 0; }
    .content { padding: 14px; }
    .avatar { width: 38px; height: 38px; flex: 0 0 38px; font-size: 16px; }
    .message header h1 { font-size: 18px; }
}
