:root {
  --navy: #17324d;
  --blue: #2167d5;
  --blue-soft: #eaf2ff;
  --ink: #1d2935;
  --muted: #697887;
  --line: #dbe3ea;
  --surface: #ffffff;
  --canvas: #f4f7fa;
  --success: #117a50;
  --danger: #b52b35;
  --shadow: 0 8px 28px rgba(23, 50, 77, .09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-size: 15px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea { font: inherit; }
button, .primary, .secondary, .danger { border-radius: 8px; border: 1px solid transparent; padding: .72rem 1rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-decoration: none; }
button:disabled { opacity: .7; cursor: wait; }
.primary { background: var(--blue); color: white; }
.primary:hover { background: #1958ba; text-decoration: none; }
.secondary { background: white; color: var(--navy); border-color: var(--line); }
.danger { background: white; color: var(--danger); border-color: #efc6ca; }
.compact { padding: .48rem .7rem; font-size: .9rem; }
.wide { width: 100%; }
.topbar { height: 68px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--navy); }
.brand:hover { text-decoration: none; }
.brand span:last-child { display: flex; line-height: 1; flex-direction: column; }
.brand small { font-size: .65rem; letter-spacing: .18em; margin-top: 4px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(145deg, #2167d5, #17324d); color: white; display: inline-grid; place-items: center; font-weight: 800; }
.brand-mark.large { width: 54px; height: 54px; border-radius: 14px; font-size: 1.5rem; }
.top-actions { display: flex; align-items: center; gap: 16px; }
.top-actions form, .message-tools form { margin: 0; }
.account-pill { color: var(--success); background: #e7f7f0; border-radius: 99px; padding: 6px 10px; font-size: .82rem; }
.text-link, .text-button { border: 0; background: none; padding: 0; color: var(--blue); }
.page-shell { padding: 28px; }
.content-width { max-width: 1180px; margin: 0 auto; }
.content-width.narrow { max-width: 880px; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 15%, #edf5ff, transparent 35%), linear-gradient(135deg, #f7f9fb, #e8eef5); }
.login-card { width: min(430px, 100%); background: white; border-radius: 18px; box-shadow: var(--shadow); padding: 34px; border: 1px solid rgba(219,227,234,.8); }
.login-brand { display: flex; gap: 15px; align-items: center; margin-bottom: 28px; }
.login-brand h1 { margin: 0 0 5px; font-size: 1.55rem; }
.login-brand p { margin: 0; color: var(--muted); font-size: .9rem; }
.stack-form, .compose-form { display: grid; gap: 16px; }
label { color: #3c4c5c; font-weight: 600; font-size: .9rem; display: grid; gap: 7px; }
input, textarea { width: 100%; border: 1px solid #cbd7e1; border-radius: 8px; background: white; padding: .72rem .8rem; color: var(--ink); }
input:focus, textarea:focus { outline: 3px solid rgba(33,103,213,.14); border-color: var(--blue); }
textarea { resize: vertical; line-height: 1.5; }
.security-note { color: var(--muted); font-size: .82rem; text-align: center; margin: 22px 0 0; }
.alert { border-radius: 9px; padding: 12px 15px; margin: 0 0 18px; border: 1px solid; }
.alert.success { color: #0a6943; background: #e9f8f1; border-color: #bfe8d6; }
.alert.error { color: #98212b; background: #fff0f1; border-color: #f1c7ca; }
.mail-layout { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 230px minmax(0,1fr); }
.sidebar { padding: 24px 16px; border-right: 1px solid var(--line); background: #f8fafc; }
.compose-button { display: block; background: var(--blue); color: white; text-align: center; padding: 13px 16px; border-radius: 10px; font-weight: 700; margin-bottom: 22px; }
.compose-button:hover { text-decoration: none; background: #1958ba; }
.nav-item { display: block; color: #405263; padding: 11px 14px; border-radius: 8px; margin: 3px 0; }
.nav-item.active { color: #174f9f; background: var(--blue-soft); font-weight: 700; }
.mail-panel { min-width: 0; background: white; }
.panel-head { min-height: 91px; padding: 20px 26px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.panel-head h1 { margin: 0 0 3px; font-size: 1.4rem; }
.muted { color: var(--muted); font-size: .85rem; }
.search-form { display: flex; width: min(500px, 50%); }
.search-form input { border-radius: 9px 0 0 9px; background: #f7f9fb; }
.search-form button { border-radius: 0 9px 9px 0; background: var(--navy); color: white; }
.message-list { display: grid; }
.message-row { display: grid; grid-template-columns: 32px minmax(180px, .7fr) minmax(250px, 2fr) 150px; align-items: center; color: #405263; gap: 12px; min-height: 72px; padding: 10px 24px; border-bottom: 1px solid #edf1f4; }
.message-row:hover { background: #f8fafc; text-decoration: none; }
.message-row.unread { color: var(--ink); background: #f7faff; }
.message-row.unread .sender, .message-row.unread strong { font-weight: 800; }
.star { color: #d59600; font-size: 1.15rem; }
.sender, .message-preview strong, .message-preview small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.message-preview small { color: var(--muted); margin-top: 4px; }
.message-row time { font-size: .8rem; text-align: right; color: var(--muted); }
.empty-state, .center-card { text-align: center; padding: 70px 24px; color: var(--muted); }
.empty-state span, .status-icon { display: inline-grid; place-items: center; width: 52px; height: 52px; background: #e9f8f1; color: var(--success); border-radius: 50%; font-size: 1.4rem; font-weight: 800; }
.empty-state h2, .center-card h1 { color: var(--ink); }
.center-card { max-width: 650px; margin: 60px auto; background: white; border-radius: 16px; box-shadow: var(--shadow); }
.error-icon { background: #fff0f1; color: var(--danger); }
.pagination { display: flex; justify-content: flex-end; padding: 22px; }
.back-row { margin: 0 0 14px; }
.card, .message-card { background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 3px 14px rgba(23,50,77,.05); padding: 26px; }
.card h1, .card h2 { margin-top: 0; }
.message-header { display: flex; justify-content: space-between; gap: 30px; border-bottom: 1px solid var(--line); padding-bottom: 20px; }
.message-header h1 { font-size: 1.55rem; margin: 0 0 15px; }
.message-header p { margin: 5px 0; color: #566675; }
.message-header time { color: var(--muted); white-space: nowrap; }
.message-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.email-body { padding: 24px 5px; line-height: 1.6; overflow-wrap: anywhere; }
.email-body pre { white-space: pre-wrap; font-family: inherit; }
.email-body table { max-width: 100%; }
.attachments { border-top: 1px solid var(--line); padding-top: 18px; }
.attachments h2 { font-size: 1rem; }
.attachment-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.attachment-grid a { display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; min-width: 220px; }
.attachment-grid small { color: var(--muted); }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }
.admin-page > h1 { margin-top: 0; }
.connection-card { display: flex; align-items: center; justify-content: space-between; gap: 30px; margin-bottom: 20px; }
.connection-card h2 { margin: 6px 0; }
.eyebrow { color: var(--muted); letter-spacing: .12em; font-size: .72rem; font-weight: 800; }
.status-good { color: var(--success); margin-bottom: 0; }
.disconnect-form { display: flex; align-items: end; gap: 8px; }
.admin-grid { display: grid; grid-template-columns: minmax(280px,.65fr) minmax(440px,1.35fr); gap: 20px; }
.check-label { display: flex; align-items: center; gap: 9px; }
.check-label input { width: auto; }
.user-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.user-row small { display: block; color: var(--muted); margin-top: 3px; }
.status-badge { color: var(--success); background: #e7f7f0; border-radius: 99px; padding: 4px 8px; font-size: .75rem; }
.status-badge.off { color: #72565a; background: #ece7e8; }
.password-inline { grid-column: 1 / -1; display: flex; gap: 8px; }
.password-inline input { flex: 1; }
.audit-card { margin-top: 20px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 10px; vertical-align: top; }
th { color: #526373; background: #f7f9fb; }
@media (max-width: 900px) {
  .account-pill, .user-name { display: none; }
  .mail-layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px; }
  .sidebar nav { display: flex; overflow-x: auto; }
  .compose-button { margin: 0 0 10px; }
  .message-row { grid-template-columns: 28px 1fr 105px; }
  .message-preview { grid-column: 2 / -1; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .topbar { padding: 0 14px; }
  .top-actions { gap: 9px; }
  .page-shell { padding: 14px; }
  .panel-head { display: block; padding: 16px; }
  .search-form { width: 100%; margin-top: 13px; }
  .message-row { padding: 10px 12px; grid-template-columns: 24px 1fr; }
  .message-row time { grid-column: 2; text-align: left; }
  .message-header, .connection-card { display: block; }
  .message-header time { display: block; margin-top: 12px; }
  .two-columns { grid-template-columns: 1fr; }
  .disconnect-form { display: grid; margin-top: 18px; }
}

