:root {
    --bg-top: #19436b;
    --bg-bottom: #2f77b8;
    --panel: rgba(214, 233, 250, 0.94);
    --panel-strong: rgba(240, 248, 255, 0.98);
    --accent: #1d3b5c;
    --accent-soft: #3379e8;
    --ok: #2d8a52;
    --warn: #c75031;
    --shadow: 0 18px 40px rgba(7, 23, 38, 0.22);
    --border: rgba(12, 43, 74, 0.25);
    --text: #132235;
    --muted: #4e6883;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.25), transparent 30%),
        linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

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

.page-shell {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.topbar {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 18px;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 12px;
    color: var(--muted);
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: 40px;
}

.subtitle,
.muted,
.session-host {
    color: var(--muted);
}

.session-box {
    text-align: right;
}

.session-user {
    font-weight: 700;
    font-size: 18px;
}

.flash {
    padding: 14px 18px;
    margin-bottom: 18px;
}

.flash-success {
    border-left: 8px solid var(--ok);
}

.flash-error {
    border-left: 8px solid var(--warn);
}

.flash-info {
    border-left: 8px solid var(--accent-soft);
}

.login-card {
    max-width: 560px;
    margin: 40px auto 0;
    padding: 28px;
}

.stack-form {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(29, 59, 92, 0.2);
    background: rgba(255, 255, 255, 0.85);
    color: var(--text);
}

textarea {
    min-height: 280px;
    resize: vertical;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 12px;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    min-width: 120px;
}

.button.subtle {
    background: rgba(29, 59, 92, 0.08);
    color: var(--accent);
    border: 1px solid rgba(29, 59, 92, 0.15);
}

.button.danger {
    background: #b53a3a;
}

.button.full {
    width: 100%;
}

.app-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 18px;
}

.sidebar {
    padding: 18px;
    height: fit-content;
}

.mailboxes {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}

.mailbox-link {
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.42);
}

.mailbox-link.active {
    background: var(--accent-soft);
    color: #fff;
}

.content {
    min-width: 0;
}

.admin-layout {
    display: block;
}

.admin-panel {
    padding: 22px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.admin-card {
    display: grid;
    gap: 8px;
    padding: 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.55);
}

.list-panel,
.viewer,
.composer {
    padding: 22px;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 16px;
    margin-bottom: 16px;
}

.message-list {
    display: grid;
}

.message-row {
    display: grid;
    grid-template-columns: 1.1fr 1.8fr 160px 100px;
    gap: 14px;
    padding: 14px 10px;
    border-bottom: 1px solid rgba(29, 59, 92, 0.1);
}

.message-row.unread {
    background: rgba(255, 255, 255, 0.35);
    font-weight: 700;
}

.message-row.read {
    color: #2d4a67;
}

.message-subject,
.message-from {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.empty-state {
    padding: 28px 8px;
    text-align: center;
    color: var(--muted);
}

.pagination,
.toolbar,
.move-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 18px;
}

.meta-grid {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.5);
}

.message-body {
    margin-top: 18px;
    padding: 14px;
    background: var(--panel-strong);
    border-radius: 14px;
    border: 1px solid rgba(29, 59, 92, 0.08);
}

.message-body pre {
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

.mail-frame {
    width: 100%;
    min-height: 520px;
    border: none;
    background: #fff;
    border-radius: 10px;
}

.attachments {
    margin-top: 18px;
    display: grid;
    gap: 8px;
}

.attachment {
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.56);
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.notes {
    margin-top: 18px;
    display: grid;
    gap: 8px;
    color: var(--muted);
}

@media (max-width: 960px) {
    .app-grid {
        grid-template-columns: 1fr;
    }

    .message-row {
        grid-template-columns: 1fr;
    }

    .topbar,
    .section-title {
        flex-direction: column;
        align-items: start;
    }

    .session-box {
        text-align: left;
    }
}
