:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #2557d6;
  --danger: #c0392b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #e7edff, var(--bg));
  color: var(--text);
}
.shell {
  width: min(960px, calc(100% - 32px));
  margin: 40px auto;
  display: grid;
  gap: 16px;
}
.card {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(16,24,40,.08);
}
.hero { display: grid; gap: 22px; }
h1 { margin: 4px 0 8px; font-size: clamp(32px, 6vw, 54px); letter-spacing: -0.04em; }
h2 { margin: 0; }
.label { margin: 0; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.email-form { display: grid; grid-template-columns: 1fr 220px auto; gap: 10px; }
input, select, button {
  min-height: 52px;
  border-radius: 14px;
  border: 1px solid var(--line);
  font-size: 16px;
  padding: 0 16px;
}
input, select { background: #fff; color: var(--text); }
button {
  background: var(--accent);
  color: #fff;
  border: 0;
  font-weight: 700;
  cursor: pointer;
}
button:hover { filter: brightness(.96); }
.secondary { background: #eef2ff; color: var(--accent); }
.danger { color: var(--danger); background: #fff1f0; }
.address-row, .status-card, .section-head, .status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.address-row strong { display: block; font-size: 22px; margin-top: 4px; word-break: break-all; }
.dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; flex: 0 0 10px; }
.dot.idle { background: #98a2b3; }
.dot.wait { background: #f79009; box-shadow: 0 0 0 6px rgba(247,144,9,.12); }
.dot.ok { background: #12b76a; box-shadow: 0 0 0 6px rgba(18,183,106,.12); }
.messages { display: grid; gap: 12px; margin-top: 18px; }
.messages.empty { color: var(--muted); padding: 20px; border: 1px dashed var(--line); border-radius: 16px; }
.message {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: #fff;
}
.message-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.message-subject { font-weight: 800; }
.message-from, .message-time { color: var(--muted); font-size: 13px; }
.message-body {
  white-space: pre-wrap;
  background: #f9fafb;
  padding: 12px;
  border-radius: 12px;
  max-height: 260px;
  overflow: auto;
}
@media (max-width: 760px) {
  .email-form { grid-template-columns: 1fr; }
  .address-row, .status-card, .section-head { align-items: flex-start; flex-direction: column; }
  button { width: 100%; }
}

.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
.logout { min-width: 110px; }
.login-shell {
  min-height: 100vh;
  align-content: center;
  max-width: 480px;
}
.login-card { display: grid; gap: 16px; }
.login-form { display: grid; gap: 12px; }
.login-form label { display: grid; gap: 6px; }
.error-text {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}
@media (max-width: 760px) {
  .topbar { justify-content: stretch; }
}

body.is-logging-out main,
body.is-logging-out .shell {
  opacity: 0;
  pointer-events: none;
}

/* Fix long email content overflowing card */
.message,
.message-head,
.message-body,
.messages {
  min-width: 0;
  max-width: 100%;
}

.message {
  overflow: hidden;
}

.message-head {
  flex-wrap: wrap;
}

.message-subject,
.message-from,
.message-time,
.message-body {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message-body {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}
