:root {
  --bg: #f4f7f5;
  --panel: #ffffff;
  --line: #d7dfd9;
  --text: #17211b;
  --muted: #66756c;
  --brand: #17603b;
  --brand-2: #0f7a4a;
  --danger: #b4233a;
  --danger-bg: #fff1f2;
  --soft: #eef4f0;
  --shadow: 0 12px 28px rgba(23, 33, 27, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

input,
select {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(15, 122, 74, 0.12);
}

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.login-panel {
  width: min(420px, 100%);
  margin: 12vh auto 0;
}

.login-panel h1,
.topbar h1 {
  margin: 4px 0 0;
  font-size: 1.55rem;
  line-height: 1.2;
}

.eyebrow {
  margin: 0;
  color: var(--brand-2);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-form {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.error {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--danger);
}

.app-view {
  display: grid;
  gap: 14px;
}

.topbar,
.heading,
.actions,
.layout,
.content-grid {
  display: flex;
}

.topbar,
.heading {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 360px) 1fr;
  gap: 12px;
  align-items: end;
}

.domain-row label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.actions {
  gap: 10px;
  flex-wrap: wrap;
}

.actions.compact {
  margin-top: 10px;
}

.btn-primary,
.btn-secondary,
.btn-danger,
.link-button {
  border: 0;
  border-radius: 8px;
  padding: 9px 13px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-secondary {
  background: var(--soft);
  color: #173324;
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.link-button {
  min-height: 0;
  padding: 0;
  background: transparent;
  color: var(--brand-2);
  text-decoration: underline;
}

.layout {
  align-items: flex-start;
  gap: 14px;
}

.mailbox-panel {
  width: 340px;
  flex: 0 0 340px;
}

.content-grid {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(320px, 1.15fr);
  gap: 14px;
}

.detail {
  grid-column: 1 / -1;
}

.heading h2,
.messages h2,
.detail h2 {
  margin: 0;
  font-size: 1.05rem;
}

.heading span,
.meta,
small,
.empty {
  color: var(--muted);
}

.inbox code {
  display: block;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
  overflow-wrap: anywhere;
}

.mailbox-list,
.messages ul {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.mailbox-list {
  display: grid;
  gap: 8px;
}

.mailbox-item button,
.msg button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
  color: var(--text);
  text-align: left;
}

.mailbox-item button {
  padding: 9px 10px;
}

.mailbox-item.active button {
  border-color: #72bb95;
  background: #edf8f2;
}

.mailbox-item span,
.subject {
  display: block;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.mailbox-item small,
.meta {
  display: block;
  margin-top: 3px;
  font-size: 0.86rem;
}

.msg button {
  margin-bottom: 9px;
  padding: 10px;
}

.empty {
  padding: 10px 0;
}

.detail h3,
.detail h4 {
  margin: 14px 0 8px;
}

.detail p {
  margin: 7px 0;
  overflow-wrap: anywhere;
}

.detail pre {
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
  padding: 10px;
}

.detail ul {
  margin: 0;
  padding-left: 18px;
}

.mail-html-frame {
  width: 100%;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 980px) {
  .layout,
  .content-grid,
  .controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .mailbox-panel {
    width: auto;
    flex: none;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

  .actions button,
  .btn-primary,
  .btn-secondary,
  .btn-danger {
    width: 100%;
  }
}
