:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --nav: #101828;
  --blue: #155eef;
  --blue-soft: #eaf1ff;
  --green: #0f7a4f;
  --green-soft: #e8f6ef;
  --amber: #a15c07;
  --amber-soft: #fff3d6;
  --red: #b42318;
  --red-soft: #fee4e2;
  --teal: #0e6f73;
  --teal-soft: #def7f8;
  --shadow: 0 10px 28px rgba(16, 24, 40, 0.08);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  background: var(--nav);
  color: #f2f4f7;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 18px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  color: #101828;
  font-weight: 900;
}

.brand strong, .account strong { display: block; font-size: 16px; }
.brand small, .account small { color: #cbd5e1; font-size: 12px; }

.nav { display: grid; gap: 8px; }
.nav-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  color: #cbd5e1;
  background: transparent;
  text-align: left;
}
.nav-item.active, .nav-item:hover { background: #1d2939; color: #fff; }
.nav-item span {
  min-width: 24px;
  height: 22px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: #344054;
  font-size: 12px;
}

.safety {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 18px;
  display: flex;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #1d2939;
}
.safety small { display: block; color: #cbd5e1; margin-top: 3px; }
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  background: #fdb022;
}

.main { padding: 28px 24px 40px; overflow: hidden; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
h1, h2, p { margin: 0; }
h1 { font-size: 30px; letter-spacing: 0; }
h2 { font-size: 18px; letter-spacing: 0; }
p { color: var(--muted); margin-top: 4px; }

.account {
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.account small { color: var(--muted); }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 142px 118px 140px auto auto;
  gap: 10px;
  margin-bottom: 16px;
}
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
input, select { height: 44px; padding: 0 12px; }
textarea {
  width: 100%;
  min-height: 210px;
  resize: vertical;
  padding: 14px;
  line-height: 1.55;
}

.primary, .secondary, .danger {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  padding: 0 16px;
  font-weight: 800;
}
.primary { background: var(--blue); color: #fff; }
.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.danger { background: var(--red); color: #fff; }
.hidden { display: none !important; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.metric small { display: block; color: var(--muted); margin-bottom: 8px; }
.metric strong { font-size: 32px; line-height: 1; }

.workspace {
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(500px, 1fr);
  gap: 16px;
  align-items: start;
}
.list-panel, .reply-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  min-height: calc(100vh - 265px);
}
.panel-head {
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-head small { color: var(--muted); }

.message-list { display: grid; }
.message {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 14px;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid #edf1f6;
  text-align: left;
  background: #fff;
  color: var(--ink);
}
.message:hover, .message.active { background: var(--surface-soft); }
.stripe { width: 8px; border-radius: 999px; background: var(--blue); }
.message.approval .stripe { background: var(--red); }
.message.internal .stripe { background: var(--teal); }
.message.marketing .stripe { background: var(--amber); }
.message.information .stripe { background: var(--blue); }
.message strong { display: block; margin-bottom: 6px; }
.message p { font-size: 14px; margin: 0 0 8px; }
.time { color: var(--muted); font-size: 12px; white-space: nowrap; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}
.badge.approval { color: var(--red); background: var(--red-soft); }
.badge.internal { color: var(--teal); background: var(--teal-soft); }
.badge.marketing { color: var(--amber); background: var(--amber-soft); }
.badge.information { color: var(--blue); background: var(--blue-soft); }
.badge.green { color: var(--green); background: var(--green-soft); }
.badge.amber { color: var(--amber); background: var(--amber-soft); }
.badge.neutral { color: var(--muted); background: #eef2f6; }

.detail {
  padding: 0;
  max-height: calc(100vh - 322px);
  overflow: auto;
  background: #fff;
}
.empty, .empty-detail {
  min-height: 240px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 22px;
}
.empty strong { display: block; color: var(--ink); margin-bottom: 6px; }
.section-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
}
.mail-reader {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
}
.mail-reader-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
}
.mail-reader-head h2 {
  font-size: 23px;
  line-height: 1.25;
  margin-bottom: 16px;
}
.mail-sender {
  display: flex;
  gap: 10px;
  align-items: center;
}
.avatar.mini {
  width: 36px;
  height: 36px;
  font-size: 14px;
  flex: 0 0 auto;
}
.mail-sender small,
.mail-meta span,
.mail-meta time {
  display: block;
  color: var(--muted);
  font-size: 13px;
}
.mail-meta {
  text-align: right;
  line-height: 1.5;
  padding-top: 3px;
}
.mail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 12px;
}
.summary-strip {
  border-left: 3px solid var(--blue);
  background: var(--blue-soft);
  padding: 12px 14px;
  margin: 14px 0 18px;
}
.summary-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 5px;
}
.summary-strip strong {
  font-size: 14px;
  line-height: 1.45;
}
.mail-body {
  border: 0;
  border-radius: 0;
  background: #fff;
  padding: 8px 0 0;
  margin: 0;
}
.mail-body pre {
  margin: 0;
  max-height: 44vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.62;
}
.reply-composer {
  padding: 18px 24px 24px;
  background: var(--surface-soft);
}
.composer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}
.composer-head .section-title {
  display: block;
  margin: 0 0 4px;
}
.outlook-link {
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}
.outlook-link:hover { text-decoration: underline; }
.reply-composer textarea {
  min-height: 170px;
  background: #fff;
}
.reply-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.25fr;
  gap: 10px;
  margin-top: 12px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #101828;
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 10;
}

@media (max-width: 1050px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .safety { position: static; margin-top: 18px; }
  .workspace { grid-template-columns: 1fr; }
  .detail { max-height: none; }
  .toolbar { grid-template-columns: 1fr 150px 130px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .topbar, .toolbar { grid-template-columns: 1fr; display: grid; }
  .metrics { grid-template-columns: 1fr; }
  .reply-actions { grid-template-columns: 1fr; }
  .mail-reader-head, .composer-head { grid-template-columns: 1fr; display: grid; }
  .mail-meta { text-align: left; }
  .account { min-width: 0; width: 100%; }
}
