:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  color: #183044;
  background: #eef3f7;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% 0%, rgba(61, 153, 184, 0.14), transparent 32rem),
    #eef3f7;
}

button {
  font: inherit;
}

.page-shell {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0 72px;
}

.page-header {
  margin-bottom: 28px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: #237894;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  color: #102c3f;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.15;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 0;
  color: #17384d;
  font-size: 21px;
}

.subtitle {
  margin-bottom: 0;
  color: #647b8a;
  font-size: 16px;
}

.page-message {
  margin: 0 0 20px;
  padding: 12px 14px;
  border: 1px solid #ecc8ca;
  border-radius: 11px;
  color: #99383f;
  background: #fff4f4;
  font-size: 14px;
}

.panel {
  margin-top: 20px;
  padding: 26px;
  border: 1px solid #dce6ec;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 40px rgba(27, 67, 91, 0.08);
}

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

.online-count {
  color: #237894;
  font-size: 15px;
}

.user-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px 180px;
  gap: 12px;
  margin-bottom: 16px;
}

.user-toolbar input,
.user-toolbar select {
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid #cad9e1;
  border-radius: 10px;
  outline: none;
  color: #17384d;
  background: #fbfdfe;
  font: inherit;
}

.user-toolbar input:focus,
.user-toolbar select:focus {
  border-color: #4292aa;
  box-shadow: 0 0 0 3px rgba(66, 146, 170, 0.14);
}

.user-table-wrap {
  overflow-x: auto;
  border: 1px solid #dce6ec;
  border-radius: 14px;
}

.user-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: #ffffff;
}

.user-table th,
.user-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #e5edf1;
  text-align: left;
  white-space: nowrap;
}

.user-table th {
  color: #617886;
  background: #f5f9fb;
  font-size: 13px;
}

.user-table tbody tr:last-child td {
  border-bottom: 0;
}

.user-table tbody tr:hover {
  background: #f8fbfc;
}

.user-table th:last-child,
.user-table td:last-child {
  width: 130px;
  text-align: right;
}

.user-empty-row td {
  height: 150px;
  color: #8295a1;
  text-align: center !important;
}

.user-enter-button {
  min-height: 36px;
  padding: 0 14px;
  font-size: 13px;
}

.control-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.control-header .button {
  flex: 0 0 auto;
  margin-top: 3px;
}

.chain-label {
  color: #78909e;
  font-size: 13px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.status-card {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  padding: 17px;
  border: 1px solid #e3ebef;
  border-radius: 14px;
  background: #f8fafb;
}

.status-icon {
  display: grid;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  color: #28768f;
  background: #e0f0f5;
  font-weight: 700;
}

.status-name {
  margin-bottom: 4px;
  color: #617886;
  font-size: 13px;
}

.status-value {
  position: relative;
  margin-bottom: 0;
  padding-left: 14px;
  font-size: 15px;
  font-weight: 700;
}

.status-value::before {
  position: absolute;
  top: 50%;
  left: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  transform: translateY(-50%);
  content: "";
}

.status-offline {
  color: #8999a3;
}

.status-online {
  color: #278153;
}

.status-busy {
  color: #287f9b;
}

.device-list {
  min-height: 190px;
  overflow: hidden;
  border: 1px dashed #cad9e1;
  border-radius: 14px;
  background: #fafcfd;
}

.device-list-header,
.device-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 100px;
  align-items: center;
  gap: 16px;
}

.device-list-header {
  padding: 10px 16px;
  color: #718895;
  font-size: 13px;
  font-weight: 700;
}

.scan-actions,
.device-pagination {
  display: flex;
  align-items: center;
  gap: 10px;
}

.device-control-bar {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.ble-compact-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
}

.ble-compact-status .status-icon {
  flex-basis: 36px;
  width: 36px;
  height: 36px;
}

.device-control-bar input {
  width: 100%;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid #cad9e1;
  border-radius: 10px;
  outline: none;
  color: #17384d;
  background: #fbfdfe;
}

.device-control-bar input:focus {
  border-color: #4292aa;
  box-shadow: 0 0 0 3px rgba(66, 146, 170, 0.14);
}

.device-control-bar input:disabled {
  cursor: not-allowed;
  background: #f1f5f7;
}

.device-count,
.device-pagination span {
  color: #718895;
  font-size: 13px;
}

.device-pagination {
  justify-content: center;
  margin-top: 14px;
}

.device-pagination .button {
  min-height: 36px;
  padding: 0 14px;
}

.device-option {
  width: 100%;
  min-height: 68px;
  padding: 13px 16px;
  border: 0;
  border-bottom: 1px solid #e3ebef;
  color: #284b60;
  background: #ffffff;
  cursor: pointer;
  text-align: left;
}

.device-option:last-child {
  border-bottom: 0;
}

.device-option:hover {
  background: #f2f8fa;
}

.device-option[aria-selected="true"] {
  box-shadow: inset 4px 0 #2384a0;
  background: #eaf6f9;
}

.device-details {
  display: contents;
}

.device-details strong,
.device-details small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-details small,
.device-signal {
  color: #7a909d;
  font-size: 12px;
}

.device-signal {
  text-align: right;
}

.empty-state {
  display: grid;
  min-height: 188px;
  padding: 28px;
  place-content: center;
  text-align: center;
}

.empty-icon {
  display: block;
  margin-bottom: 8px;
  color: #8aa8b7;
  font-size: 38px;
  line-height: 1;
}

.empty-state p {
  margin-bottom: 5px;
  color: #466273;
  font-weight: 700;
}

.empty-state small {
  color: #8a9ba5;
}

.data-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
}

.data-format-control {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #718895;
  font-size: 13px;
}

.data-format-control select {
  min-height: 38px;
  padding: 0 34px 0 12px;
  border: 1px solid #cad9e1;
  border-radius: 10px;
  outline: none;
  color: #17384d;
  background: #fbfdfe;
  font: inherit;
}

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

.field-group label {
  color: #466273;
  font-size: 14px;
  font-weight: 700;
}

.field-group textarea {
  width: 100%;
  min-height: 92px;
  padding: 13px 14px;
  resize: vertical;
  border: 1px solid #cad9e1;
  border-radius: 11px;
  outline: none;
  color: #17384d;
  background: #fbfdfe;
  font: 15px/1.6 Consolas, "Courier New", monospace;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field-group textarea:focus {
  border-color: #4292aa;
  box-shadow: 0 0 0 3px rgba(66, 146, 170, 0.14);
}

.field-group textarea:disabled {
  cursor: not-allowed;
  background: #f1f5f7;
}

.field-group small {
  color: #8295a1;
}

.data-composer .button {
  min-width: 116px;
}

.log-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 28px 0 12px;
}

.log-heading h3 {
  margin: 0;
  color: #466273;
  font-size: 15px;
}

.log-legend {
  display: flex;
  gap: 12px;
}

.log-heading-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.button-small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.log-note {
  margin: 0 0 8px;
  color: #8295a1;
  font-size: 12px;
}

.export-status {
  min-height: 18px;
  margin: -4px 0 10px;
  color: #718895;
  font-size: 12px;
  text-align: right;
}

.legend-item {
  position: relative;
  padding-left: 12px;
  color: #718895;
  font-size: 12px;
}

.legend-item::before {
  position: absolute;
  top: 50%;
  left: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translateY(-50%);
  content: "";
}

.legend-send::before {
  background: #3284a0;
}

.legend-receive::before {
  background: #55a275;
}

.data-log {
  min-height: 190px;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid #dbe5ea;
  border-radius: 14px;
  background: #f8fafb;
}

.data-record {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-bottom: 1px solid #e1e9ed;
}

.data-record:last-child {
  border-bottom: 0;
}

.data-record strong,
.data-record p {
  margin: 0;
  font-size: 13px;
  white-space: pre-wrap;
}

.data-record strong {
  color: #3d8b5f;
}

.data-record-send strong {
  color: #3284a0;
}

.data-record code,
.data-record pre {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.data-record code {
  color: #31576a;
}

.data-record pre {
  color: #596f7b;
  font: inherit;
}

.data-empty-state {
  min-height: 188px;
}

.button-row {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

.button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.button:not(:disabled):hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button-primary {
  color: #ffffff;
  background: #167d99;
}

.button-secondary {
  color: #226f88;
  border-color: #b9d5df;
  background: #edf7fa;
}

.button-danger {
  color: #a53b43;
  border-color: #ebc8ca;
  background: #fff4f4;
}

@media (max-width: 680px) {
  .page-shell {
    width: min(100% - 20px, 960px);
    padding: 32px 0 44px;
  }

  .panel {
    padding: 20px;
    border-radius: 15px;
  }

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

  .user-toolbar {
    grid-template-columns: 1fr;
  }

  .control-header {
    flex-direction: column;
  }

  .control-header .button {
    width: auto;
  }

  .chain-label {
    display: none;
  }

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

  .button-row {
    flex-direction: column;
  }

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

  .scan-actions {
    width: 100%;
    align-items: stretch;
  }

  .device-control-bar input {
    width: 100%;
  }

  .scan-actions .button {
    flex: 1;
  }

  .device-list-header,
  .device-option {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) 72px;
    gap: 8px;
  }

  .data-composer {
    grid-template-columns: 1fr;
  }

  .data-format-control {
    width: 100%;
    justify-content: space-between;
  }

  .log-heading-actions {
    align-items: flex-end;
    flex-direction: column;
  }

  .button {
    width: 100%;
  }
}
