:root {
  --bg: #f7f9fc;
  --panel: #ffffff;
  --text: #152033;
  --muted: #5b6b84;
  --border: #d8e0ec;
  --accent: #1063ff;
  --ok: #1c9d5a;
  --warn: #c98300;
  --bad: #c73737;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(180deg, #f7f9fc 0%, #eef3fa 100%);
  color: var(--text);
}

.topbar {
  padding: 16px;
  background: #ffffffdd;
  backdrop-filter: blur(4px);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

h1 {
  margin: 0;
  font-size: 22px;
}

h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

h3 {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.meta-block {
  min-width: 280px;
  font-size: 12px;
  line-height: 1.5;
}

.container {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 6px 18px #1020400a;
}

.controls .row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.controls .row + .row {
  margin-top: 8px;
}

.wrap {
  flex-wrap: wrap;
}

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

input,
select,
button {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: pointer;
  min-width: 120px;
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: wait;
}

.status {
  font-size: 13px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.grid.cards {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #ffffff;
}

.card p {
  margin: 8px 0 0;
  font-size: 24px;
  font-weight: 700;
}

.timeline-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  min-height: 140px;
  max-height: 140px;
  overflow-x: auto;
  padding: 6px 0;
}

.bar-group {
  width: 10px;
  min-width: 10px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 1px;
}

.bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
}

.bar.start {
  background: #3c78ff;
}

.bar.delivered {
  background: #1c9d5a;
}

.bar.retry {
  background: #d88a00;
}

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

.table-wrap {
  overflow: auto;
}

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

#eventCountsTable td:nth-child(1),
#eventCountsTable td:nth-child(3),
#eventCountsTable td:nth-child(4),
#eventCountsTable td:nth-child(5) {
  white-space: nowrap;
}

#eventCountsTable td:nth-child(2) {
  font-family: Consolas, monospace;
  font-size: 12px;
}

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

th {
  position: sticky;
  top: 0;
  background: #f7fbff;
  color: #2a4264;
}

.samples {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.sample {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.sample .meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.sample .msg {
  font-family: Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.meta-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  font-size: 13px;
}

@media (max-width: 980px) {
  .grid.cards {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

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

  .topbar {
    flex-direction: column;
  }

  .meta-block {
    min-width: 0;
  }
}

@media (max-width: 560px) {
  .grid.cards {
    grid-template-columns: 1fr;
  }

  .card p {
    font-size: 22px;
  }

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

  .btn-primary {
    width: 100%;
  }
}
