:root {
  --bg: #0b0f17;
  --panel: #121826;
  --panel-alt: #182032;
  --border: #253047;
  --text: #e6edf7;
  --muted: #8ea0bd;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --danger: #ef4444;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}
.hidden { display: none !important; }

.login-shell {
  display: grid;
  place-items: center;
  height: 100vh;
}
.login-card {
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
}
.login-card h1 { margin: 0 0 4px; color: var(--accent); }
.subtitle { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
input, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
button {
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-alt);
}
button.primary, #login-btn {
  background: var(--accent);
  color: #111827;
  border-color: transparent;
}
button.primary:hover, #login-btn:hover { background: var(--accent-hover); }
button.danger { border-color: var(--danger); color: #fca5a5; }
#login-btn { width: 100%; margin-top: 6px; }
.error { margin-top: 12px; color: #fca5a5; font-size: 13px; }

.app-shell {
  display: grid;
  grid-template-columns: 220px 340px 1fr;
  height: 100vh;
}
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px;
}
.brand { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.brand strong { color: var(--accent); font-size: 18px; }
#mailbox-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.mailbox-item {
  display: flex; justify-content: space-between; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; font-size: 14px;
}
.mailbox-item:hover, .mailbox-item.active { background: var(--panel-alt); }
.badge { background: var(--accent); color: #111827; border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 700; }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 10px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 8px; }

.message-list-pane {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.toolbar { display: flex; gap: 8px; padding: 10px; border-bottom: 1px solid var(--border); }
.toolbar input { margin-top: 0; }
#message-list { flex: 1; overflow-y: auto; }
.msg-row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.msg-row:hover, .msg-row.active { background: var(--panel-alt); }
.msg-row.unread .row-subject { font-weight: 700; color: #fff; }
.row-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.row-subject { font-size: 14px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.reader-pane { display: flex; flex-direction: column; overflow: hidden; }
.empty-state { margin: auto; color: var(--muted); }
#reader-content { display: flex; flex-direction: column; height: 100%; }
.reader-header { padding: 18px 22px; border-bottom: 1px solid var(--border); }
.reader-header h2 { margin: 0 0 8px; font-size: 20px; }
.meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.reader-actions { display: flex; gap: 8px; }
.msg-body { flex: 1; overflow: auto; margin: 0; padding: 20px 22px; white-space: pre-wrap; font-family: inherit; line-height: 1.55; }
.msg-iframe { flex: 1; border: 0; background: #fff; width: 100%; }

.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72);
  display: grid; place-items: center;
}
.modal-card {
  width: 560px; max-width: 94vw; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; padding: 20px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-header h3 { margin: 0; }
.modal-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
