:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --ink: #16202a;
  --muted: #64707d;
  --line: #d8e0e7;
  --accent: #126a70;
  --accent-2: #254f8f;
  --danger: #b42318;
  --ok: #137333;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  min-height: 36px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.96);
}

button.ghost {
  background: #e6edf2;
  color: var(--ink);
}

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

.login-body {
  display: grid;
  place-items: center;
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(24, 37, 50, 0.08);
}

.login-panel {
  padding: 28px;
}

.login-panel h1 {
  margin: 0 0 20px;
  font-size: 28px;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 24px;
  background: #fbfcfd;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.topbar span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.layout {
  width: min(1440px, calc(100vw - 32px));
  margin: 18px auto 32px;
  display: grid;
  grid-template-columns: minmax(520px, 1.1fr) minmax(360px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-title h2 {
  margin: 0;
}

.panel-help {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.grid-form.compact {
  margin-bottom: 16px;
}

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

input,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 7px 10px;
}

input:focus,
select:focus {
  outline: 2px solid rgba(18, 106, 112, 0.18);
  border-color: var(--accent);
}

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

.switch-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.switch-row input {
  width: 18px;
  min-height: 18px;
}

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

.message {
  color: var(--danger);
  min-height: 20px;
  margin: 0;
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #f7f9fb;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e6edf2;
  color: var(--ink);
  font-size: 12px;
}

.pill.on {
  background: #dff3e6;
  color: var(--ok);
}

.pill.off {
  background: #fde6e3;
  color: var(--danger);
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 40px;
}

.checks label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  color: var(--ink);
}

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

.queue-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.queue-devices {
  display: grid;
  gap: 8px;
}

.queue-device {
  display: grid;
  grid-template-columns: auto 0.8fr 1.1fr 0.55fr 1fr 0.55fr auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.queue-position {
  display: grid;
  align-content: end;
  justify-items: center;
  gap: 4px;
  min-width: 58px;
}

.queue-position > strong {
  color: var(--accent-2);
}

.queue-order-actions {
  display: flex;
  gap: 3px;
}

.queue-order-actions button {
  min-width: 27px;
  min-height: 27px;
  padding: 0 7px;
}

.queue-remove {
  min-height: 36px;
}

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

.field-help {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.row-actions button {
  min-height: 30px;
  padding: 0 10px;
}

.event-list {
  display: grid;
  gap: 8px;
}

.event {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfd;
  font-size: 13px;
}

.event strong {
  display: block;
  margin-bottom: 4px;
}

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

.hidden {
  display: none !important;
}

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

  .queue-device {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .topbar {
    padding: 14px;
  }

  .layout {
    width: calc(100vw - 20px);
    margin-top: 10px;
    gap: 10px;
  }

  .panel {
    padding: 14px;
  }

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

  .queue-device {
    grid-template-columns: 1fr;
  }
}
