:root {
  color-scheme: dark;
  --bg: #080a0d;
  --panel: #131820;
  --panel-2: #171f2a;
  --line: #2b3542;
  --text: #eef4fb;
  --muted: #91a0b3;
  --green: #16c784;
  --green-deep: #063f2b;
  --red: #ff3b5f;
  --red-deep: #4b0715;
  --amber: #f6b73c;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

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

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.reset-form {
  margin: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--amber);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(32px, 4vw, 54px);
  line-height: 1;
}

h2 {
  font-size: 20px;
}

.export-button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #202a36;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.danger-button {
  border-color: rgba(255, 59, 95, 0.55);
  background: #35121a;
  color: #ffb3c0;
}

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

.control-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.4fr) minmax(320px, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

input {
  width: 100%;
  min-height: 58px;
  padding: 0 16px;
  border: 2px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--panel);
  color: var(--text);
  font-size: 22px;
}

input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 4px rgba(246, 183, 60, 0.14);
}

.reader-card {
  display: grid;
  align-content: center;
  min-height: 82px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.reader-card strong {
  margin-top: 6px;
  font-size: 24px;
  overflow-wrap: anywhere;
}

.reader-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.reader-state {
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
}

.reader-state.connected {
  color: var(--green);
}

.reader-state.disconnected {
  color: var(--red);
}

.status-panel {
  display: grid;
  align-content: center;
  min-height: 280px;
  margin-bottom: 16px;
  padding: 30px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  overflow-wrap: anywhere;
}

.status-panel.good {
  border-color: var(--green);
  background: var(--green-deep);
}

.status-panel.bad {
  border-color: var(--red);
  background: var(--red-deep);
}

.status-panel.waiting {
  border-color: var(--amber);
}

.status-label {
  font-size: clamp(42px, 7vw, 96px);
  font-weight: 900;
  line-height: 0.95;
}

.status-value {
  margin-top: 18px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: clamp(24px, 3vw, 42px);
  font-weight: 800;
}

.status-meta {
  margin-top: 14px;
  color: var(--muted);
  font-size: 20px;
  font-weight: 700;
}

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

.stat {
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stat span {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 48px;
  line-height: 1;
}

.debug-panel,
.history-wrap {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

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

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

td {
  font-size: 17px;
}

th:first-child,
td:first-child {
  width: 120px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 118px;
}

th:last-child,
td:last-child {
  width: 180px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 90px;
}

.nfc-cell {
  font-family: "SFMono-Regular", Consolas, monospace;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  min-height: 30px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.pill.unique {
  background: rgba(22, 199, 132, 0.16);
  color: #65efb4;
}

.pill.duplicate {
  background: rgba(255, 59, 95, 0.18);
  color: #ff8ca1;
}

.empty {
  color: var(--muted);
  text-align: center;
}

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

.diagnostic-item {
  min-height: 110px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.diagnostic-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.diagnostic-grid.compact .diagnostic-item {
  min-height: 92px;
  padding: 14px;
}

.diagnostic-grid.compact .diagnostic-item strong,
.diagnostic-grid.compact .diagnostic-item pre {
  font-size: 15px;
}

.diagnostic-item.wide {
  grid-column: 1 / -1;
}

.diagnostic-item span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.diagnostic-item strong,
.diagnostic-item pre {
  margin: 0;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 20px;
  font-weight: 800;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

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

.login-panel {
  width: min(430px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.login-panel h1 {
  margin-bottom: 22px;
  font-size: 34px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-error {
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid rgba(255, 59, 95, 0.55);
  border-radius: 8px;
  background: rgba(255, 59, 95, 0.12);
  color: #ffb3c0;
  font-weight: 800;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 14px;
  }

  .top-bar,
  .control-row,
  .stats-grid,
  .diagnostic-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .status-panel {
    min-height: 230px;
    padding: 22px;
  }

  th:last-child,
  td:last-child {
    display: none;
  }

  .diagnostic-item.wide {
    grid-column: auto;
  }
}
