:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1c2430;
  --muted: #647080;
  --line: #d9dee7;
  --accent: #265f99;
  --accent-strong: #1f4d7d;
  --accent-soft: #e6f0fa;
  --ok: #1d7a45;
  --warn: #a45b10;
  --bad: #a23838;
  --shadow: 0 12px 32px rgba(35, 45, 60, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

button,
input {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  padding: 0 14px;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

button.primary:hover:not(:disabled) {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: #fff;
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.app-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.15;
}

.app-header p,
.message-toolbar p {
  margin: 0;
  color: var(--muted);
}

.header-actions,
.small-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

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

.controls-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

section h2,
.message-toolbar h2 {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.25;
}

.file-picker {
  display: grid;
  place-items: center;
  min-height: 88px;
  border: 1px dashed #a9b3c1;
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
  text-align: center;
}

.file-picker input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.meta-list {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.search-box {
  display: grid;
  gap: 7px;
}

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

.search-box input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
}

.toggle-row {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.toggle-row label,
.protocol-filters label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
}

.protocol-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.protocol-filters label {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 0 11px;
}

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

.stats-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
}

.stats-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stats-grid dd {
  margin: 5px 0 0;
  font-size: 19px;
  font-weight: 800;
}

.message-panel {
  min-width: 0;
  overflow: hidden;
}

.message-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

td {
  background: #fff;
}

tr:hover td {
  background: #fbfdff;
}

.check-col {
  width: 44px;
}

.message-title {
  display: grid;
  gap: 2px;
}

.message-title strong {
  font-size: 14px;
}

.message-title span {
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

.checksum-ok {
  color: var(--ok);
  font-weight: 800;
}

.checksum-warn {
  color: var(--warn);
  font-weight: 800;
}

.checksum-bad {
  color: var(--bad);
  font-weight: 800;
}

.empty-state {
  height: 240px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 920px) {
  .app-shell {
    padding: 14px;
  }

  .app-header,
  .message-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions,
  .small-actions {
    justify-content: flex-start;
  }

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

  .table-wrap {
    max-height: none;
  }
}
