:root {
  color-scheme: light;
  --canvas: #f5f6f4;
  --surface: #ffffff;
  --surface-soft: #fafbfa;
  --text: #202932;
  --text-soft: #66717c;
  --muted: #8b949d;
  --line: #dfe3e6;
  --line-strong: #cfd5d9;
  --blue: #2563eb;
  --blue-soft: #edf3ff;
  --green: #16845a;
  --green-soft: #edf8f3;
  --orange: #ad651f;
  --orange-soft: #fff5e9;
  --red: #a94e3c;
  --red-soft: #fff4f1;
  font-family: "Avenir Next", Avenir, "PingFang SC", "Hiragino Sans GB", sans-serif;
  background: var(--canvas);
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--canvas); }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -10rem, rgb(255 255 255 / 92%) 0, transparent 33rem),
    var(--canvas);
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid rgb(37 99 235 / 22%);
  outline-offset: 2px;
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 56px);
  border-bottom: 1px solid rgb(223 227 230 / 88%);
  background: rgb(255 255 255 / 88%);
  backdrop-filter: blur(18px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 9px;
  background: #202830;
  color: #fff;
  font-family: "DIN Alternate", "Avenir Next", sans-serif;
  font-size: 11px;
  letter-spacing: -.03em;
}
.brand-divider { width: 1px; height: 14px; background: var(--line-strong); }
.brand-product { color: var(--text-soft); font-weight: 600; letter-spacing: .02em; }
.user-strip { display: flex; align-items: center; gap: 9px; color: var(--text-soft); font-size: 12px; }
.user-avatar {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: #e7eaec;
  color: #4d5964;
  font-size: 9px;
  font-weight: 800;
}
.text-button {
  min-height: 34px;
  margin-left: 2px;
  padding: 0 0 0 12px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.text-button:hover { color: var(--text); }

.app-shell { width: min(1480px, 100%); margin: 0 auto; padding: 0 clamp(20px, 4vw, 56px) 64px; }
.section-label {
  margin: 0 0 9px;
  color: var(--blue);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .14em;
}

.login-stage { display: grid; min-height: calc(100vh - 128px); place-items: center; padding: 48px 0 72px; }
.login-card {
  width: min(420px, 100%);
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 20px 58px rgb(33 43 53 / 7%);
  text-align: center;
  animation: stage-in .38s both;
}
.login-symbol {
  display: grid;
  width: 44px;
  height: 44px;
  margin: 0 auto 23px;
  place-items: center;
  border-radius: 13px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 18px;
  font-weight: 800;
}
.login-card h1 { margin: 0; font-size: clamp(28px, 6vw, 34px); font-weight: 750; letter-spacing: -.045em; }
.login-card .lead { margin: 12px auto 27px; color: var(--text-soft); font-size: 13px; line-height: 1.75; }
.primary-action {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 10px;
  background: #252e37;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
}
.primary-action:hover { transform: translateY(-1px); background: #111820; box-shadow: 0 10px 24px rgb(24 33 42 / 14%); }
.security-note { margin: 15px 0 0; color: var(--muted); font-size: 10px; }
.login-error {
  margin: 18px 0 0;
  padding: 11px 13px;
  border: 1px solid #efd7d1;
  border-radius: 9px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 11px;
}

.console { padding-top: clamp(34px, 5vw, 62px); animation: stage-in .35s both; }
.console-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; }
.console-heading h1 { margin: 0; font-size: clamp(38px, 5vw, 52px); line-height: 1; letter-spacing: -.055em; }
.heading-note { margin: 11px 0 0; color: var(--text-soft); font-size: 12px; }
.metric-rail { display: flex; gap: 8px; }
.metric-rail div {
  min-width: 94px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}
.metric-rail strong, .metric-rail span { display: block; }
.metric-rail strong { font-family: "DIN Alternate", "Avenir Next", sans-serif; font-size: 20px; letter-spacing: -.02em; }
.metric-rail span { margin-top: 2px; color: var(--muted); font-size: 9px; }
.metric-rail .metric-online strong { color: var(--green); }
.metric-rail .metric-attention strong { color: var(--orange); }

.control-rail { display: grid; grid-template-columns: minmax(260px, 1fr) auto auto; gap: 9px; margin: 28px 0 15px; }
.search-box {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
}
.search-box span { color: var(--text-soft); font-size: 16px; line-height: 1; }
.search-box:focus-within { border-color: #aebfe7; box-shadow: 0 0 0 3px rgb(37 99 235 / 8%); }
.search-box input { width: 100%; padding: 9px 4px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; }
.search-box input::placeholder { color: #9aa2aa; }
.filter-tabs { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.filter-tab, .refresh-button { border: 0; color: var(--text-soft); cursor: pointer; }
.filter-tab { min-width: 66px; padding: 8px 11px; border-radius: 7px; background: transparent; font-size: 11px; }
.filter-tab:hover { color: var(--text); }
.filter-tab.is-active { background: #252e37; color: #fff; }
.refresh-button {
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
}
.refresh-button:hover { border-color: #b9c7d2; color: var(--text); }
.refresh-button:disabled { cursor: wait; opacity: .5; }
.notice {
  padding: 34px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 13px;
  background: rgb(255 255 255 / 48%);
  color: var(--text-soft);
  font-size: 12px;
  text-align: center;
}

.device-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.device-card {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 184px;
  grid-template-rows: 1fr auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 1px 1px rgb(27 36 45 / 2%);
  animation: card-in .34s both;
  animation-delay: calc(var(--order, 0) * 25ms);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.device-card:hover { transform: translateY(-2px); border-color: #bdc9df; box-shadow: 0 12px 28px rgb(32 51 79 / 8%); }
.device-main { padding: 17px 17px 13px; }
.device-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.device-code { margin: 0; overflow: hidden; font-size: 23px; font-weight: 800; letter-spacing: -.045em; text-overflow: ellipsis; white-space: nowrap; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #f1f3f4;
  color: #707981;
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill::before { width: 5px; height: 5px; border-radius: 50%; background: #9ba3aa; content: ""; }
.status-pill.is-online { background: var(--green-soft); color: var(--green); }
.status-pill.is-online::before { background: #1e9a6a; }
.status-pill.is-attention { background: var(--orange-soft); color: var(--orange); }
.status-pill.is-attention::before { background: #d88431; }
.device-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 22px 0 0; padding-top: 12px; border-top: 1px solid #edf0f2; }
.device-facts div { min-width: 0; }
.device-facts dt { color: var(--muted); font-size: 8px; }
.device-facts dd { margin: 4px 0 0; overflow: hidden; color: #4e5964; font-size: 10px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.open-device {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  padding: 0 17px;
  border: 0;
  border-top: 1px solid #edf0f2;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}
.open-device:hover { background: var(--blue-soft); }
.empty-state { padding: 70px 20px; border: 1px dashed var(--line-strong); border-radius: 13px; background: rgb(255 255 255 / 48%); text-align: center; }
.empty-state strong, .empty-state > span { display: block; }
.empty-state strong { margin-top: 12px; font-size: 14px; }
.empty-state > span:last-child { margin-top: 6px; color: var(--muted); font-size: 11px; }
.empty-mark { color: var(--blue); font-size: 24px; }

@keyframes stage-in { from { opacity: 0; transform: translateY(7px); } }
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 1100px) {
  .device-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .console-heading { align-items: flex-start; flex-direction: column; }
  .metric-rail { width: 100%; }
  .metric-rail div { min-width: 0; flex: 1; }
  .control-rail { grid-template-columns: 1fr; }
  .refresh-button { min-height: 42px; }
}

@media (max-width: 600px) {
  .masthead { min-height: 58px; padding-inline: 16px; }
  .brand-divider, .brand-product { display: none; }
  .brand-name { font-size: 10px; }
  .user-avatar { display: none; }
  .app-shell { padding: 0 16px 42px; }
  .login-stage { min-height: calc(100vh - 100px); padding: 28px 0 48px; }
  .login-card { padding: 30px 23px; }
  .console { padding-top: 30px; }
  .console-heading h1 { font-size: 38px; }
  .metric-rail { gap: 5px; }
  .metric-rail div { padding: 9px 10px; }
  .metric-rail strong { font-size: 18px; }
  .metric-rail span { font-size: 8px; }
  .filter-tabs { width: 100%; }
  .filter-tab { flex: 1; }
  .device-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
