:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f6f8;
  color: #17202a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: #176b5b;
  color: white;
  padding: 0 14px;
  cursor: pointer;
}

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

button:disabled {
  background: #aab3bd;
  cursor: not-allowed;
}

input,
textarea {
  width: 100%;
  border: 1px solid #cfd6dd;
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
  color: #17202a;
}

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

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px;
}

.topbar,
.section-head,
.detail-head,
.actions,
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 30px;
}

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

p {
  margin-bottom: 0;
  color: #607080;
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  border: 1px solid #dfe4e8;
  border-radius: 8px;
  background: white;
  padding: 14px;
}

.notice {
  margin-bottom: 14px;
  border: 1px solid #e2b9bd;
  border-radius: 6px;
  background: #fff4f5;
  color: #8a2430;
  padding: 10px 12px;
  font-weight: 650;
}

.notice.ok {
  border-color: #b8d7c8;
  background: #f1fbf6;
  color: #176b5b;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid #dfe4e8;
}

.tab-button {
  min-height: 44px;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: #526170;
}

.tab-button.active {
  background: white;
  color: #17202a;
  border: 1px solid #dfe4e8;
  border-bottom-color: white;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.layout-two {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: white;
  border: 1px solid #dfe4e8;
  border-radius: 8px;
  padding: 18px;
}

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

.button-secondary {
  background: #eef2f5;
  color: #344453;
}

.button-danger {
  background: #b4232f;
}

.instance-list,
.events {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.instance-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  border: 1px solid #d7dde3;
  background: #fbfcfd;
  color: #17202a;
  text-align: left;
}

.instance-button.active {
  border-color: #176b5b;
  background: #eef8f5;
}

.instance-name,
.event-title {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 750;
}

.instance-id,
.event-meta {
  display: block;
  margin-top: 4px;
  color: #607080;
  font-size: 12px;
}

.status-pill {
  align-self: center;
  border-radius: 999px;
  padding: 5px 9px;
  background: #e8edf2;
  color: #344453;
  font-size: 12px;
  font-weight: 750;
}

.status-connected {
  background: #dff4e9;
  color: #176b5b;
}

.status-qr,
.status-connecting,
.status-reconnecting {
  background: #fff3cd;
  color: #7a5600;
}

.status-logged-out,
.status-error,
.status-disconnected {
  background: #ffe2e5;
  color: #8a2430;
}

.detail-head {
  align-items: flex-start;
  margin-bottom: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.qr-zone {
  display: grid;
  place-items: center;
  min-height: 290px;
  border: 1px dashed #bcc6d0;
  border-radius: 8px;
  background: #fbfcfd;
  text-align: center;
  padding: 16px;
}

.qr-zone img {
  width: min(260px, 100%);
  height: auto;
}

.send-panel {
  display: grid;
  gap: 12px;
  border: 1px solid #e7ebef;
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfd;
}

.event-row {
  border: 1px solid #e0e5ea;
  border-radius: 6px;
  padding: 12px;
  background: #fbfcfd;
}

.event-row code {
  display: block;
  max-height: 180px;
  margin-top: 8px;
  overflow: auto;
  color: #526170;
  font-size: 12px;
  white-space: pre-wrap;
}

.empty-state {
  border: 1px dashed #cfd6dd;
  border-radius: 8px;
  padding: 18px;
  color: #607080;
  text-align: center;
}

.pagination {
  margin-top: 14px;
}

.pagination span {
  color: #607080;
  font-size: 13px;
  font-weight: 650;
}

@media (max-width: 900px) {
  .shell {
    padding: 18px;
  }

  .topbar,
  .section-head,
  .detail-head,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-panel,
  .layout-two,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
  }
}
