:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #687386;
  --line: #dfe5ee;
  --accent: #1663d9;
  --accent-dark: #0f4dad;
  --danger: #bc2d2d;
  --ok: #177245;
  --shadow: 0 18px 50px rgba(25, 38, 63, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

.shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p,
.hint,
small {
  color: var(--muted);
}

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

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

.panel.narrow {
  max-width: 440px;
}

.panel.wide {
  min-width: 0;
}

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

.stack {
  display: grid;
  gap: 12px;
}

.row,
.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tight {
  gap: 8px;
}

label {
  display: grid;
  gap: 6px;
  color: #303a4d;
  font-size: 13px;
  font-weight: 650;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

input:focus {
  outline: 2px solid rgba(22, 99, 217, 0.18);
  border-color: var(--accent);
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button.ghost {
  color: var(--text);
  background: #eef2f8;
}

button.danger {
  background: var(--danger);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: #263348;
  background: #edf1f7;
  font-size: 12px;
  font-weight: 800;
}

.badge.ok {
  color: #0f5733;
  background: #dff3e9;
}

.badge.busy {
  color: #774d00;
  background: #fff0cb;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}

.qrBox {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafd;
}

.qrBox img {
  width: min(230px, 100%);
  aspect-ratio: 1;
  border-radius: 8px;
  background: #fff;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 12px;
}

legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

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

.checks label,
.dialog label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 650;
}

.checks input,
.dialog input {
  width: 16px;
  min-height: 16px;
}

.search {
  width: min(320px, 100%);
}

.dialogs {
  display: grid;
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dialog {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}

.dialog:last-child {
  border-bottom: 0;
}

.dialog small {
  display: block;
  margin-top: 2px;
  font-weight: 600;
}

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

.stats div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.stats span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 20px;
  font-weight: 800;
}

.log {
  height: 300px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border-radius: 8px;
  background: #111827;
  color: #d7e0ee;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 20px, 1240px);
    padding-top: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid,
  .stats {
    grid-template-columns: 1fr;
  }

  .panelHead {
    align-items: flex-start;
    flex-direction: column;
  }
}
