:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #647184;
  --line: #d9dee7;
  --accent: #c0182d;
  --accent-dark: #941324;
  --ok: #137a4b;
  --bad: #b42318;
  --shadow: 0 12px 30px rgba(20, 31, 46, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

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

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

button.secondary {
  color: var(--ink);
  background: #e7ebf1;
}

button.secondary:hover {
  background: #dbe1ea;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 8px 10px;
  color: var(--ink);
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

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

.hidden {
  display: none !important;
}

.shell {
  min-height: 100vh;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

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

.app-view {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-actions,
.actions-row,
.list-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.user-chip {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.band,
.panel,
.mail-list,
.mail-detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.band {
  padding: 14px;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.panel {
  display: grid;
  gap: 14px;
  padding: 14px;
  box-shadow: none;
}

.subtle,
.message {
  color: var(--muted);
  font-size: 13px;
}

.message[data-type="success"] {
  color: var(--ok);
}

.message[data-type="error"] {
  color: var(--bad);
}

.form-grid,
.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto auto;
  gap: 12px;
  align-items: end;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(140px, 1fr));
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.mail-list,
.mail-detail {
  overflow: hidden;
}

.list-head {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  max-height: calc(100vh - 300px);
  min-height: 360px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef1f5;
  color: var(--muted);
  font-weight: 700;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr:focus {
  background: #f8e9ec;
  outline: none;
}

.mail-list > .message {
  padding: 12px 14px;
}

.mail-detail {
  min-height: calc(100vh - 170px);
  padding: 18px;
}

.detail-empty {
  color: var(--muted);
  display: grid;
  min-height: 260px;
  place-items: center;
  text-align: center;
}

.mail-detail dl {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 16px 0;
  font-size: 13px;
}

.mail-detail dt {
  color: var(--muted);
}

.mail-detail dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.mail-detail pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  background: #f2f4f7;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  max-height: calc(100vh - 360px);
  overflow: auto;
}

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

  .topbar,
  .topbar-actions,
  .actions-row,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .table-wrap,
  .mail-detail {
    max-height: none;
    min-height: 260px;
  }
}
