:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #19212a;
  --muted: #667085;
  --line: #d8dde6;
  --accent: #176b87;
  --accent-strong: #0f4f65;
  --danger: #b42318;
  --warn: #fff7df;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  color: var(--ink);
  font-weight: 800;
}

nav {
  display: flex;
  gap: 16px;
  flex: 1;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px;
}

.page-head,
.row-between,
.actions,
.inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.stats,
.grid {
  display: grid;
  gap: 16px;
}

.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 24px 0;
}

.stats div,
.panel,
.card,
.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.stats strong {
  display: block;
  font-size: 28px;
}

.stats span,
.muted {
  color: var(--muted);
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wide {
  max-width: 760px;
}

input,
textarea,
select,
button,
.button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
}

textarea {
  resize: vertical;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.compact {
  padding: 6px 10px;
  font-size: 13px;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
}

.control-button {
  gap: 8px;
}

.stop-control {
  border-color: var(--danger);
  background: var(--danger);
}

.stop-control:hover {
  background: #8f1d14;
}

button:disabled {
  border-color: var(--line);
  background: #d8dee2;
  color: var(--muted);
  cursor: not-allowed;
}

.ghost {
  background: transparent;
  color: var(--accent);
}

.inline input,
.inline select {
  width: auto;
}

.card {
  margin-bottom: 12px;
}

.badge {
  border-radius: 999px;
  background: #eef4f6;
  color: var(--accent-strong);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef1f5;
  color: var(--muted);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  text-transform: capitalize;
  white-space: nowrap;
}

.status-complete {
  border-color: #bdd7c9;
  background: #e8f5ee;
  color: #17633a;
}

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.reply-item {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

.modal {
  width: min(720px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  overflow: auto;
}

.modal::backdrop {
  background: rgb(25 33 42 / 55%);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-head h2 {
  margin-bottom: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
}

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

th {
  background: #eef1f5;
}

tr.warn {
  background: var(--warn);
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #f2f4f7;
  padding: 12px;
  border-radius: 6px;
}

.field-help {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f9fafb;
  padding: 12px;
}

.field-help p {
  margin: 6px 0 0;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.95em;
}

.error {
  color: var(--danger);
  font-weight: 700;
}

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-panel {
  width: min(420px, calc(100vw - 32px));
}

@media (max-width: 760px) {
  .topbar,
  .page-head,
  .row-between,
  .actions,
  .inline {
    align-items: stretch;
    flex-direction: column;
  }

  nav {
    flex-wrap: wrap;
  }

  .stats,
  .grid.two {
    grid-template-columns: 1fr;
  }
}
