:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #080b0d;
  color: #162129;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  background: #0f6b4f;
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}

button.secondary {
  border: 1px solid #c8d3d9;
  background: #fff;
  color: #162129;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 14px;
  background: #162129;
  color: #fff;
}

.topbar > div:first-child,
.station-strip > div {
  min-width: 0;
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: #a9b8c0;
  font-size: 13px;
}

h1 {
  max-width: 46vw;
  overflow: hidden;
  font-size: 22px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
}

.tab {
  background: #2b3a43;
  color: #dfe8ed;
}

.tab.active {
  background: #fff;
  color: #162129;
}

.view {
  display: none;
  min-height: 0;
  overflow: auto;
}

.view.active {
  display: block;
  flex: 1 1 auto;
}

#scanView.view.active {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  overflow: hidden;
}

.station-strip {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  background: #fff;
  border-bottom: 1px solid #dce5ea;
}

.station-strip strong,
.station-strip span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-strip span {
  margin-top: 2px;
  color: #5d6b73;
  font-size: 14px;
}

.scan-panel {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 16px;
  text-align: center;
  transition: background 140ms ease, color 140ms ease;
}

.scan-panel p {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(34px, 8vmin, 76px);
  font-weight: 850;
  line-height: 1.08;
}

.scan-panel.idle {
  background: #050607;
  color: #f4f7f8;
}

.scan-panel.good {
  background: #11845b;
  color: #fff;
}

.scan-panel.bad {
  background: #b3261e;
  color: #fff;
}

.scan-panel.purple {
  background: #5b2a86;
  color: #fff;
}

.scan-panel.gold {
  background: #d6a11d;
  color: #151007;
}

.scan-panel.silver {
  background: #c7d0d8;
  color: #162129;
}

.scanner-input {
  position: fixed;
  inset-inline-start: -200vw;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.panel,
.form-grid,
.dashboard-toolbar,
.table-wrap,
.login-panel,
.scan-history-panel {
  background: #fff;
  border: 1px solid #dce5ea;
  border-radius: 8px;
  padding: 16px;
}

.scan-history-panel {
  flex: 0 0 auto;
  margin: 0;
  border-width: 1px 0 0;
  border-radius: 0;
  padding: 8px 10px;
}

.history {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid #dce5ea;
  border-radius: 8px;
  background: #fbfcfd;
  font-size: 13px;
  line-height: 1.2;
  overflow: hidden;
}

.history li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quiet-sync {
  display: block;
  margin-top: 6px;
  color: #6b7b84;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.connection-strip {
  flex: 0 0 auto;
  min-height: 22px;
  padding: 4px 10px calc(4px + env(safe-area-inset-bottom));
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.connection-strip.online {
  background: #11845b;
}

.connection-strip.offline {
  background: #b3261e;
}

.connection-strip.server-wait {
  background: #1769aa;
}

.login-panel {
  display: grid;
  gap: 14px;
  width: min(460px, calc(100vw - 40px));
  margin: 32px auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
  margin: 18px 20px;
}

label {
  display: grid;
  gap: 6px;
  color: #34454f;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid #c8d3d9;
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: #162129;
}

.inline-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.message {
  margin: 0 20px 18px;
  color: #40535e;
}

.hidden {
  display: none !important;
}

.dashboard-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(220px, 320px) auto;
  gap: 10px;
  margin: 18px 20px;
}

.table-wrap {
  margin: 0 20px 28px;
  overflow: auto;
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid #e2e9ed;
  text-align: right;
}

th {
  color: #5d6b73;
  font-size: 13px;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 22px;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
}

.close {
  float: left;
  background: #e9eef1;
  color: #162129;
}

@media (max-width: 820px) {
  .topbar,
  .station-strip {
    align-items: center;
    flex-direction: row;
  }

  .tabs,
  .form-grid,
  .dashboard-toolbar {
    grid-template-columns: 1fr;
  }

  .topbar {
    gap: 8px;
    padding: 8px 10px;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: 18px;
  }

  .tabs {
    gap: 5px;
  }

  .tab {
    padding: 8px 9px;
    font-size: 13px;
  }

  .station-strip {
    padding: 7px 10px;
  }

  .station-strip strong {
    font-size: 14px;
  }

  .station-strip span {
    font-size: 12px;
  }

  .scan-panel p {
    font-size: clamp(32px, 10vmin, 54px);
  }

  .history li:nth-child(n + 4) {
    display: none;
  }

  .connection-strip {
    min-height: 20px;
    padding-top: 3px;
    font-size: 12px;
  }
}

@media (max-height: 520px) {
  .topbar {
    padding-block: 5px;
  }

  h1 {
    font-size: 16px;
  }

  .tab {
    padding-block: 6px;
  }

  .station-strip {
    padding-block: 5px;
  }

  .history li:nth-child(n + 3) {
    display: none;
  }
}
