:root {
  --navy: #0B121E;
  --navy-2: #131D2E;
  --navy-3: #1E293B;
  --orange: #E65A1D;
  --orange-dark: #C94B14;
  --white: #FFFFFF;
  --gray: #F1F5F9;
  --line: #E2E8F0;
  --line-2: #CBD5E1;
  --text: #1E293B;
  --muted: #64748B;
  --ok: #15803D; --ok-bg: #DCFCE7;
  --warn: #A16207; --warn-bg: #FEF9C3;
  --bad: #B91C1C; --bad-bg: #FEE2E2;
  --info: #1D4ED8; --info-bg: #DBEAFE;
  --radius: 10px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-head: 'Plus Jakarta Sans', var(--font);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--gray); -webkit-font-smoothing: antialiased; }
a { color: var(--navy-3); }
h1, h2 { font-family: var(--font-head); letter-spacing: -0.01em; color: var(--navy); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.is-hidden { display: none !important; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent; font: 600 14px var(--font); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--navy-3); }
.btn-ghost { background: var(--white); color: var(--text); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--gray); }
.btn-block { width: 100%; }
.btn-compose { background: var(--orange); color: var(--white); width: 100%; height: 42px; margin: 4px 0 20px; }
.btn-compose:hover { background: var(--orange-dark); }
.link-btn { background: none; border: 0; color: rgba(255,255,255,.65); font: 500 14px var(--font); cursor: pointer; padding: 8px 12px; }
.link-btn:hover { color: var(--white); }
form { margin: 0; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--navy) 248px, var(--gray) 248px); }
.sidebar { background: var(--navy); color: var(--white); padding: 22px 16px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: block; padding: 4px 8px 18px; }
.brand img { height: 30px; width: auto; display: block; }
.nav { flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 18px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.45); padding: 0 12px 6px; }
.nav-link { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 8px; color: rgba(255,255,255,.82); text-decoration: none; font-weight: 500; border-left: 3px solid transparent; }
.nav-link:hover { background: var(--navy-2); color: var(--white); }
.nav-link.is-active { background: var(--navy-2); color: var(--white); border-left-color: var(--orange); }
.nav-box span:first-child { font-variant-numeric: tabular-nums; }
.count { background: rgba(255,255,255,.14); color: var(--white); font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.logout { border-top: 1px solid rgba(255,255,255,.1); padding-top: 12px; }
.main { padding: 28px 36px 48px; min-width: 0; }

/* ---------- topbar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.topbar h1 { font-size: 24px; margin: 0; }
.search input { width: 320px; max-width: 100%; height: 38px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 12px; font: 14px var(--font); background: var(--white); }
.search input:focus, input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy-3); outline-offset: 1px; }

/* ---------- list ---------- */
.list { list-style: none; margin: 0; padding: 0; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.row { display: grid; grid-template-columns: 210px 1fr auto; gap: 16px; align-items: center; padding: 12px 18px; text-decoration: none; color: var(--text); }
.row:hover { background: #F8FAFC; }
.row-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.row-main { display: flex; gap: 8px; min-width: 0; overflow: hidden; white-space: nowrap; }
.row-subject { color: var(--text); flex-shrink: 0; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
.row-snippet { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.row-snippet::before { content: '— '; }
.row-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.row.is-unread { background: var(--white); }
.row.is-unread .row-who, .row.is-unread .row-subject { color: var(--navy); font-weight: 700; }
.row.is-unread { box-shadow: inset 3px 0 0 var(--orange); }
.star { color: var(--orange); margin-right: 6px; }
.tag { font-size: 12px; background: var(--gray); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; color: var(--muted); }
.total { margin-top: 10px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.empty { background: var(--white); border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 48px 24px; text-align: center; color: var(--muted); }

/* ---------- badges & alerts ---------- */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge-ok { color: var(--ok); background: var(--ok-bg); }
.badge-warn { color: var(--warn); background: var(--warn-bg); }
.badge-bad { color: var(--bad); background: var(--bad-bg); }
.badge-info { color: var(--info); background: var(--info-bg); }
.alert { padding: 12px 16px; border-radius: 8px; margin: 0 0 16px; font-size: 14px; }
.alert-ok { background: var(--ok-bg); color: #14532D; }
.alert-warn { background: var(--warn-bg); color: #713F12; }
.alert-bad { background: var(--bad-bg); color: #7F1D1D; }

/* ---------- message ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.message { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 28px; }
.message-subject { font-size: 22px; margin: 0 0 16px; overflow-wrap: anywhere; }
.meta { display: grid; grid-template-columns: 90px 1fr; gap: 4px 12px; margin: 0 0 12px; font-size: 14px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.auth { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.images-bar { padding: 8px 12px; background: var(--gray); border-radius: 8px; margin-bottom: 10px; font-size: 13px; }
.mail-frame { width: 100%; height: 70vh; min-height: 420px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); display: block; }
.attachments h2 { font-size: 15px; margin: 20px 0 8px; }
.attachments ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

/* ---------- compose ---------- */
.compose { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 28px; max-width: 900px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input[type=text], .field select, .field textarea, .login input { width: 100%; border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 12px; font: 15px var(--font); color: var(--text); background: var(--white); }
.field textarea { resize: vertical; min-height: 280px; line-height: 1.6; }
.field-cc { margin: -4px 0 14px; }
.field-cc summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.hint-bad { color: var(--bad); }
.compose-actions { display: flex; gap: 10px; }

/* ---------- login ---------- */
.login-body { background: var(--navy); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { background: var(--white); width: 100%; max-width: 380px; border-radius: 14px; padding: 32px; border-top: 4px solid var(--orange); }
.login-logo { height: 34px; width: auto; display: block; margin-bottom: 22px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p { margin: 0 0 18px; }
.login label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.login input { margin-bottom: 14px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; background: var(--gray); }
  .sidebar { position: static; height: auto; padding: 14px 16px; }
  .brand { padding: 0 0 12px; }
  .nav-group { flex-direction: row; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
  .nav-link { padding: 6px 10px; border-left: 0; border-bottom: 2px solid transparent; }
  .nav-link.is-active { border-bottom-color: var(--orange); }
  .nav-link .count { margin-left: 6px; }
  .btn-compose { margin: 0 0 12px; }
  .main { padding: 18px 16px 40px; }
  .topbar { flex-direction: column; align-items: stretch; }
  .search input { width: 100%; }
  .row { grid-template-columns: 1fr auto; gap: 4px 10px; }
  .row-who { grid-column: 1; }
  .row-meta { grid-column: 2; grid-row: 1; }
  .row-main { grid-column: 1 / -1; flex-direction: column; gap: 0; white-space: normal; }
  .row-subject { max-width: 100%; white-space: nowrap; }
  .row-snippet { white-space: nowrap; }
  .row-snippet::before { content: ''; }
  .message, .compose { padding: 18px 16px; }
  .meta { grid-template-columns: 70px 1fr; }
}
