:root {
  --navy-950: #06111f;
  --navy-900: #0a192b;
  --navy-800: #10243a;
  --navy-700: #17334f;
  --cyan-500: #19c2c8;
  --cyan-400: #35dde0;
  --blue-500: #3f7cff;
  --paper: #f4f7fb;
  --white: #fff;
  --text: #172235;
  --muted: #6f7d90;
  --line: #dfe6ef;
  --danger: #e6576b;
  --warning: #f2b84b;
  --success: #21a67a;
  --shadow: 0 18px 50px rgba(4, 19, 38, .12);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea, select { font: inherit; }
a { color: inherit; text-decoration: none; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 10% 15%, rgba(25, 194, 200, .22), transparent 28%),
    radial-gradient(circle at 90% 85%, rgba(63, 124, 255, .25), transparent 32%),
    linear-gradient(145deg, var(--navy-950), var(--navy-800));
}
.login-shell { width: min(1040px, 100%); display: grid; grid-template-columns: 1.05fr .95fr; border-radius: 28px; overflow: hidden; box-shadow: 0 35px 100px rgba(0,0,0,.32); }
.login-story { padding: 68px; color: white; background: linear-gradient(145deg, rgba(25,194,200,.16), rgba(5,14,27,.15)); backdrop-filter: blur(10px); }
.login-story h1 { font-size: clamp(40px, 6vw, 74px); line-height: .95; margin: 60px 0 24px; letter-spacing: -.055em; }
.login-story p { max-width: 440px; color: #b9c9da; font-size: 18px; line-height: 1.65; }
.login-card { padding: 68px 58px; background: rgba(255,255,255,.98); display: flex; flex-direction: column; justify-content: center; }
.login-card h2 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.03em; }
.login-card > p { margin: 0 0 34px; color: var(--muted); }
.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: .04em; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: var(--navy-950); background: linear-gradient(135deg, var(--cyan-400), #7cf2d5); box-shadow: 0 8px 26px rgba(25,194,200,.28); }
.brand small { display: block; font-weight: 500; font-size: 10px; color: #8ba2b8; letter-spacing: .14em; }

.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field label { font-size: 13px; font-weight: 700; color: #45556a; }
.field input, .field textarea, .field select, .search-input {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; color: var(--text); background: white; outline: none; transition: .2s ease;
}
.field input:focus, .field textarea:focus, .field select:focus, .search-input:focus { border-color: var(--cyan-500); box-shadow: 0 0 0 4px rgba(25,194,200,.12); }
.field textarea { min-height: 240px; resize: vertical; line-height: 1.55; }
.btn { border: 0; border-radius: 12px; padding: 12px 18px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; cursor: pointer; font-weight: 750; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #041620; background: linear-gradient(135deg, var(--cyan-400), #78ead0); box-shadow: 0 10px 28px rgba(25,194,200,.22); }
.btn-dark { color: white; background: var(--navy-800); }
.btn-ghost { color: #405268; background: #edf2f7; }
.btn-danger { color: #a7293d; background: #fff0f2; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 10px; }
.login-card .btn { width: 100%; margin-top: 8px; padding: 14px; }
.secure-note { margin-top: 24px; display: flex; gap: 9px; color: var(--muted); font-size: 12px; line-height: 1.45; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { background: var(--navy-950); color: white; padding: 26px 18px; display: flex; flex-direction: column; min-height: 100vh; }
.sidebar .brand { padding: 0 10px 28px; }
.compose-link { margin: 8px 4px 22px; }
.nav-list { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; color: #aebed0; border-radius: 11px; font-weight: 650; }
.nav-item:hover, .nav-item.active { color: white; background: var(--navy-800); }
.nav-item.active { box-shadow: inset 3px 0 var(--cyan-400); }
.badge { min-width: 24px; height: 22px; padding: 0 7px; border-radius: 999px; display: grid; place-items: center; background: rgba(255,255,255,.1); font-size: 11px; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding: 18px 9px 0; }
.account { font-size: 12px; color: #9cb0c4; overflow-wrap: anywhere; margin-bottom: 12px; }
.logout-button { width: 100%; background: transparent; color: #b8c7d5; border: 1px solid rgba(255,255,255,.12); }

.main { min-width: 0; }
.topbar { height: 80px; padding: 0 30px; display: flex; align-items: center; gap: 18px; background: white; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.menu-toggle { display: none; }
.search { flex: 1; max-width: 680px; position: relative; }
.search-input { padding-left: 42px; background: #f6f8fb; }
.search::before { content: '⌕'; position: absolute; left: 15px; top: 9px; font-size: 22px; color: #8290a2; }
.top-title { margin-left: auto; font-weight: 800; color: #35465b; }
.content { padding: 28px 30px 48px; }
.content-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.content-header h1 { margin: 0 0 5px; font-size: 28px; letter-spacing: -.035em; }
.content-header p { margin: 0; color: var(--muted); }
.panel { background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 32px rgba(24,50,79,.055); overflow: hidden; }
.message-list { display: grid; }
.message-row { display: grid; grid-template-columns: 42px minmax(150px, .75fr) minmax(220px, 1.8fr) 78px 68px; align-items: center; min-height: 68px; border-bottom: 1px solid #edf1f5; padding: 0 16px; transition: background .15s ease; }
.message-row:last-child { border-bottom: 0; }
.message-row:hover { background: #f7fafc; }
.message-row.unread { background: #f0fbfb; font-weight: 700; }
.message-row.unread:hover { background: #e8f8f8; }
.avatar { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: #07525a; background: #d9f7f4; font-size: 11px; font-weight: 800; }
.sender, .subject-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subject-line span { color: var(--muted); font-weight: 450; }
.message-date, .message-size { color: var(--muted); font-size: 12px; text-align: right; }
.empty-state { padding: 70px 24px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--text); font-size: 19px; margin-bottom: 8px; }
.pagination { margin-top: 18px; display: flex; justify-content: flex-end; gap: 8px; }

.flash-stack { display: grid; gap: 10px; margin-bottom: 18px; }
.flash { padding: 13px 15px; border-radius: 12px; border: 1px solid; }
.flash-success { color: #126b51; background: #ebfbf5; border-color: #bdebdc; }
.flash-error { color: #962b3c; background: #fff0f2; border-color: #f4c6ce; }

.reader { padding: 28px; }
.reader-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.reader h1 { margin: 0 0 18px; font-size: 28px; letter-spacing: -.035em; }
.meta-grid { display: grid; grid-template-columns: 58px 1fr; gap: 7px 14px; color: var(--muted); font-size: 13px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.meta-grid strong { color: #3b4c60; }
.message-body { padding: 28px 0 12px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.mail-frame { width: 100%; min-height: 440px; border: 0; background: white; }
.attachments { border-top: 1px solid var(--line); padding-top: 20px; display: flex; flex-wrap: wrap; gap: 10px; }
.attachment { padding: 10px 12px; border-radius: 10px; background: #f0f4f8; font-size: 13px; }
.attachment small { color: var(--muted); }

.compose-panel { max-width: 980px; padding: 28px; }
.compose-grid { display: grid; grid-template-columns: 1fr 220px; gap: 0 18px; }
.compose-grid .wide { grid-column: 1 / -1; }
.compose-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.file-picker { position: relative; overflow: hidden; }
.file-picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

@media (max-width: 820px) {
  .login-shell { grid-template-columns: 1fr; max-width: 520px; }
  .login-story { display: none; }
  .login-card { padding: 48px 32px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 30; transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.is-open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .top-title { display: none; }
  .content { padding: 20px 14px 38px; }
  .content-header { align-items: flex-start; flex-direction: column; }
  .message-row { grid-template-columns: 42px minmax(0, 1fr) 62px; padding: 7px 10px; }
  .message-row .subject-line { grid-column: 2 / 4; color: var(--muted); font-size: 13px; }
  .message-size { display: none; }
  .compose-grid { grid-template-columns: 1fr; }
  .compose-grid .wide { grid-column: auto; }
  .reader { padding: 20px; }
}
