:root {
  color-scheme: light;
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  font-size: 16px;
  color: #1d2730;
  background: #f4f6f7;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: #f4f6f7; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.auth-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef1f2;
}

.auth-panel {
  width: min(400px, 100%);
  padding: 32px;
  background: #fff;
  border: 1px solid #d7dde0;
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(24, 38, 48, .08);
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: #1769aa;
  font-weight: 700;
  font-size: 20px;
}

.brand-mark.small { width: 36px; height: 36px; font-size: 16px; }
h1 { margin: 18px 0 26px; font-size: 24px; }
h2 { margin: 0; font-size: 18px; }
label { display: block; margin: 15px 0 7px; color: #46545e; font-size: 14px; }

input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: #17212a;
  background: #fff;
  border: 1px solid #bfc9ce;
  border-radius: 4px;
  outline: none;
}

textarea { resize: vertical; min-height: 132px; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: #1769aa; box-shadow: 0 0 0 3px rgba(23, 105, 170, .12); }

button {
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid #1769aa;
  border-radius: 4px;
  color: #fff;
  background: #1769aa;
  font-weight: 600;
}

form > button[type="submit"] { width: 100%; margin-top: 20px; }
button:hover { background: #11598f; }
button:disabled { opacity: .55; cursor: wait; }
button.secondary { color: #34434d; background: #fff; border-color: #b8c3c8; }
button.secondary:hover { background: #edf1f2; }
button.danger { color: #a12a2a; border-color: #d7aaaa; }

.form-status { min-height: 22px; margin: 12px 0 0; color: #a12a2a; font-size: 14px; }
.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px max(24px, calc((100vw - 1280px) / 2));
  background: #fff;
  border-bottom: 1px solid #d8dfe2;
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-row strong, .brand-row span { display: block; }
.brand-row span { margin-top: 2px; color: #65737c; font-size: 13px; }
.topbar nav { display: flex; gap: 8px; }
.dashboard { max-width: 1280px; margin: 0 auto; padding: 24px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 22px;
  background: #24313a;
  color: #fff;
  border-radius: 6px;
  overflow: hidden;
}

.metrics div { padding: 18px 20px; border-right: 1px solid #43515a; }
.metrics div:last-child { border-right: 0; }
.metrics span { display: block; color: #c9d1d5; font-size: 13px; }
.metrics strong { display: block; margin-top: 5px; font-size: 25px; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .75fr); gap: 20px; }
.panel, .messages-section { background: #fff; border: 1px solid #d7dde0; border-radius: 6px; }
.panel { padding: 22px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.inline-status { color: #27733f; font-size: 13px; }
.muted { color: #738089; font-size: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.send-panel #send-button { width: auto; min-width: 128px; }

.device-list { margin-top: 14px; border-top: 1px solid #e3e7e9; }
.device-item { padding: 14px 0; border-bottom: 1px solid #e3e7e9; }
.device-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.device-name { font-weight: 600; }
.device-meta { margin-top: 5px; color: #6a7780; font-size: 12px; word-break: break-all; }
.status-dot { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; background: #87939a; }
.status-dot.online { background: #2f8a4d; }

.messages-section { margin-top: 20px; overflow: hidden; }
.messages-section > .section-heading { padding: 18px 20px; border-bottom: 1px solid #dfe4e6; }
.filter-label { margin: 0 0 0 auto; }
#message-filter { width: 116px; min-height: 36px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 13px 15px; text-align: left; vertical-align: top; border-bottom: 1px solid #e4e8ea; }
th { color: #53616a; background: #f8f9f9; font-size: 13px; font-weight: 600; }
td { font-size: 14px; }
.message-title { display: block; font-weight: 600; }
.message-content { display: block; max-width: 520px; margin-top: 4px; color: #59666e; white-space: pre-wrap; word-break: break-word; }
.badge { display: inline-block; padding: 3px 7px; border-radius: 3px; background: #e9edef; color: #45525b; font-size: 12px; }
.badge.important { color: #943232; background: #f8e5e5; }
.badge.read { color: #236b3a; background: #e4f3e9; }
.badge.displayed { color: #735716; background: #f7efda; }
.empty-state { padding: 30px; text-align: center; color: #7a878e; }

dialog { width: min(440px, calc(100% - 32px)); padding: 24px; border: 1px solid #c9d1d5; border-radius: 6px; }
dialog::backdrop { background: rgba(20, 30, 36, .45); }
.icon-close { width: 34px; min-height: 34px; padding: 0; font-size: 23px; color: #47545c; background: #fff; border-color: #c6ced2; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: 420px; padding: 12px 16px; color: #fff; background: #24313a; border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }

@media (max-width: 850px) {
  .topbar { align-items: flex-start; padding: 10px 14px; }
  .topbar nav { flex-wrap: wrap; justify-content: flex-end; }
  .dashboard { padding: 14px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics div:nth-child(2) { border-right: 0; }
  .metrics div:nth-child(-n+2) { border-bottom: 1px solid #43515a; }
  .workspace { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .auth-panel { padding: 24px 20px; }
  .topbar { display: block; }
  .topbar nav { margin-top: 10px; justify-content: flex-start; }
  .topbar nav button { flex: 1; padding: 7px 8px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .metrics div { padding: 14px; }
  .panel { padding: 17px; }
}

