:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #172033;
  --muted: #647084;
  --line: #dce3ee;
  --strong-line: #cbd5e1;
  --accent: #13715f;
  --accent-dark: #0d5548;
  --accent-soft: #e4f5ef;
  --warning: #a15c00;
  --danger: #b42318;
  --shadow: 0 18px 44px rgba(28, 38, 64, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(245, 247, 251, 0)),
    var(--bg);
}

html {
  width: 100%;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: 100%;
  min-height: 100vh;
  padding: 28px;
  overflow-x: hidden;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  width: 100%;
  min-height: calc(100vh - 56px);
  max-width: 1440px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.side {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: #fbfcff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: white;
  font-weight: 800;
  background: var(--accent);
  border-radius: 8px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 23px;
  line-height: 1.18;
}

h2 {
  font-size: 24px;
  line-height: 1.2;
}

h3 {
  font-size: 16px;
}

.lookup-form {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 44px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  outline: none;
}

input {
  padding: 0 12px;
}

select {
  padding: 0 10px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(19, 113, 95, 0.14);
}

.token-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
}

.icon-button,
.ghost,
.primary {
  height: 44px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  background: var(--surface);
}

.icon-button {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.options {
  display: grid;
  grid-template-columns: 1fr 116px;
  align-items: end;
  gap: 12px;
}

.checkline {
  display: flex;
  height: 44px;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--strong-line);
  border-radius: 8px;
}

.checkline input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.primary {
  width: 100%;
  color: white;
  font-weight: 800;
  border-color: var(--accent);
  background: var(--accent);
}

.primary:hover {
  background: var(--accent-dark);
}

.primary:disabled,
.ghost:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.status-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}

.dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  background: var(--warning);
  border-radius: 50%;
}

.dot.ok {
  background: var(--accent);
}

.dot.error {
  background: var(--danger);
}

.content {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  background: var(--surface);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 30px 18px;
}

.actions {
  display: flex;
  gap: 10px;
}

.ghost {
  min-width: 96px;
  padding: 0 14px;
  color: var(--text);
  font-weight: 700;
}

.ghost:hover:not(:disabled),
.icon-button:hover {
  background: var(--surface-muted);
}

.code-panel {
  display: grid;
  grid-template-columns: minmax(120px, auto) minmax(180px, 1fr) minmax(180px, auto);
  align-items: center;
  gap: 18px;
  margin: 0 30px 22px;
  padding: 18px 20px;
  border: 1px solid #c5e0d7;
  border-radius: 8px;
  background: var(--accent-soft);
}

.code-panel p,
.code-panel span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.code-value {
  overflow: hidden;
  color: var(--accent-dark);
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-area {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  min-height: 0;
  border-top: 1px solid var(--line);
}

.mail-list-wrap {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  border-right: 1px solid var(--line);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.mail-list {
  min-height: 0;
  overflow: auto;
  background: var(--surface-muted);
}

.mail-item {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 16px 18px;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 0;
  border-bottom: 1px solid var(--line);
}

.mail-item:hover,
.mail-item.active {
  background: #eef8f4;
}

.mail-item strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-meta {
  display: flex;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.mail-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill {
  width: max-content;
  max-width: 100%;
  padding: 4px 8px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.mail-detail {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 24px 30px;
}

.detail-head {
  display: grid;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-head h3 {
  font-size: 21px;
  line-height: 1.28;
}

.detail-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.detail-body {
  max-width: 860px;
  margin-top: 20px;
  color: #263247;
  font-size: 15px;
  line-height: 1.68;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
}

.toast {
  position: fixed;
  right: 28px;
  bottom: 28px;
  max-width: min(420px, calc(100vw - 56px));
  padding: 13px 16px;
  color: white;
  background: #172033;
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.error {
  background: var(--danger);
}

@media (max-width: 980px) {
  .shell {
    padding: 0;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .side {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .mail-area {
    grid-template-columns: 1fr;
  }

  .mail-list-wrap {
    min-height: 320px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  .side,
  .toolbar,
  .mail-detail {
    padding-left: 18px;
    padding-right: 18px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .code-panel {
    grid-template-columns: 1fr;
    margin-left: 18px;
    margin-right: 18px;
  }

  .code-value {
    font-size: 36px;
  }

  .options {
    grid-template-columns: 1fr;
  }
}
