* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f4f6f8;
  color: #17202a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

a {
  color: #1769e0;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button,
.primary {
  border: 1px solid #d0d7de;
  border-radius: 6px;
  background: #fff;
  color: #17202a;
  padding: 8px 12px;
  cursor: pointer;
}

.primary {
  background: #1769e0;
  border-color: #1769e0;
  color: #fff;
}

.full {
  width: 100%;
}

.topbar {
  height: 58px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid #d8dee4;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.muted {
  color: #667085;
  margin-left: 8px;
}

.section-head,
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.section-head h1,
.panel h2 {
  margin: 0;
}

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

.stat,
.panel,
.login-panel {
  background: #fff;
  border: 1px solid #d8dee4;
  border-radius: 8px;
}

.stat {
  padding: 18px;
}

.stat span {
  display: block;
  color: #667085;
}

.stat strong {
  display: block;
  font-size: 30px;
  margin-top: 8px;
}

.stat.danger strong {
  color: #c73535;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-two.wide-left {
  grid-template-columns: minmax(760px, 1.35fr) minmax(360px, .65fr);
}

.panel {
  padding: 16px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

th,
td {
  border-bottom: 1px solid #e6ebf0;
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  color: #667085;
  font-weight: 600;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eaf1ff;
  color: #1769e0;
}

.badge.timed_out {
  background: #ffecec;
  color: #c73535;
}

.badge.replied {
  background: #e9f7ef;
  color: #18794e;
}

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

.inline-form,
.actions form {
  display: inline;
}

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: #1769e0;
}

.danger-text {
  color: #c73535;
}

.filter-bar {
  display: grid;
  grid-template-columns: 140px 140px 1fr 1fr 1.4fr 90px;
  gap: 10px;
  margin: 18px 0;
}

.filter-bar input,
.filter-bar select,
.login-panel input,
.form-grid input,
.form-grid select {
  width: 100%;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  max-height: 720px;
  overflow: auto;
}

.message-card {
  border: 1px solid #e6ebf0;
  border-radius: 8px;
  padding: 10px;
  background: #fafbfc;
}

.message-card.origin-5 {
  background: #eef7ff;
}

.message-meta,
.message-foot {
  display: flex;
  justify-content: space-between;
  color: #667085;
  gap: 8px;
}

.message-text {
  margin: 8px 0;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty {
  color: #667085;
  text-align: center;
  padding: 18px;
}

.login-panel {
  max-width: 360px;
  margin: 80px auto;
  padding: 24px;
}

.login-panel label,
.form-grid p {
  display: block;
  margin: 12px 0;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.form-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.form-row label {
  margin: 0;
  color: #17202a;
  font-weight: 600;
}

.form-row-toggle {
  display: block;
}

.toggle-button {
  width: 240px;
  min-height: 34px;
  padding: 6px 14px;
  border-color: #cfd7e3;
  background: #f5f7fb;
  color: #475467;
  text-align: center;
  font-weight: 600;
}

.toggle-button.is-active {
  border-color: #1769e0;
  background: #1769e0;
  color: #fff;
}

.hidden-checkbox {
  display: none;
}

.hidden-checkbox input {
  display: none;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .42);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal[aria-hidden="false"] {
  display: flex;
}

.modal-card {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  padding: 20px;
}

.modal-card.small {
  width: min(460px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h2 {
  margin: 0;
}

.icon {
  width: 34px;
  height: 34px;
  padding: 0;
}

.notice {
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  background: #e9f7ef;
}

.notice.error {
  background: #ffecec;
}

.config-status {
  margin: 14px 0 18px;
  padding: 12px;
  border: 1px solid #e6ebf0;
  border-radius: 8px;
  background: #fafbfc;
}

.config-status .muted {
  margin: 0;
}

@media (max-width: 980px) {
  .stats-grid,
  .grid-two,
  .grid-two.wide-left,
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .toggle-button {
    width: 100%;
  }

  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
    gap: 10px;
  }
}
