:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --text: #1b2430;
  --muted: #637083;
  --line: #d8e0ea;
  --primary: #1266a8;
  --primary-dark: #0d4f84;
  --success: #147a55;
  --danger: #b42318;
  --warning: #9a6700;
  --radius: 8px;
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  background:
    linear-gradient(90deg, rgba(18,102,168,.92), rgba(18,102,168,.62)),
    url("../assets/control-room.jpg");
  background-size: cover;
  background-position: center;
}

.auth-panel {
  min-height: 100vh;
  background: rgba(255,255,255,.96);
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid rgba(255,255,255,.5);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
  background: var(--primary);
  font-weight: 700;
}

.auth-title {
  margin: 0 0 24px;
  font-size: 26px;
}

.auth-tools {
  position: fixed;
  top: 18px;
  right: 18px;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  color: var(--text);
  background: #fff;
}

.password-control {
  position: relative;
}

.password-control .input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  display: grid;
  place-items: center;
  min-width: 36px;
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  color: var(--primary);
  background: var(--surface-2);
  font-size: 16px;
  line-height: 1;
  transform: translateY(-50%);
}

.password-control input::-ms-reveal,
.password-control input::-ms-clear {
  display: none;
}

.password-toggle:focus-visible,
.icon-button:focus-visible,
.small-button:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.textarea {
  resize: vertical;
  min-height: 88px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.primary-button,
.secondary-button,
.small-button,
.icon-button,
.danger-button {
  border: 1px solid transparent;
  border-radius: var(--radius);
  min-height: 38px;
  padding: 8px 14px;
  background: #fff;
}

.primary-button {
  color: #fff;
  background: var(--primary);
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  color: var(--primary);
  border-color: var(--line);
}

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

.small-button,
.icon-button {
  min-height: 34px;
  padding: 6px 10px;
  border-color: var(--line);
}

.link-button {
  border: 0;
  color: var(--primary);
  background: transparent;
  padding: 0;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 236px;
  background: #17212f;
  color: #eef5ff;
  padding: 18px 14px;
  z-index: 20;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 19;
  display: none;
  background: rgba(15, 23, 42, .42);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 18px;
}

.brand-text {
  font-size: 16px;
  font-weight: 700;
}

.nav {
  display: grid;
  gap: 5px;
}

.nav a {
  border-radius: var(--radius);
  padding: 11px 12px;
  color: #c8d6e5;
}

.nav a.active,
.nav a:hover {
  background: #253448;
  color: #fff;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 62px;
  margin-left: 236px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 22px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.topbar .icon-button {
  margin-right: auto;
  display: none;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.role-pill {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
}

.app-main {
  margin-left: 236px;
  padding: 22px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-title {
  margin: 0;
  font-size: 22px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar .input {
  max-width: 320px;
}

.stats-grid,
.detail-grid,
.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 700;
}

.notice-panel {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  color: var(--text);
  background: #eaf4fb;
}

.notice-panel p {
  margin: 0;
  white-space: pre-line;
}

.section-title {
  margin: 0 0 12px;
  font-size: 16px;
}

.table-wrap {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #f8fafc;
  font-size: 13px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.row-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
}

.status.online {
  color: var(--success);
  background: #e6f5ef;
}

.status.offline {
  color: var(--muted);
  background: var(--surface-2);
}

.status.disabled,
.status.danger {
  color: var(--danger);
  background: #fcebea;
}

.device-visual {
  position: relative;
  min-height: 220px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, #dce6ee, #aab8c4);
  border: 1px solid #9cabb8;
}

.device-screen {
  position: absolute;
  inset: 58px 16% auto 16%;
  height: 78px;
  display: grid;
  place-items: center;
  color: #b7ffcf;
  background: #111820;
  border: 4px solid #26323f;
  font-size: 30px;
  font-weight: 700;
}

.device-map {
  position: relative;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  aspect-ratio: 1280 / 720;
  background: #fff url("../assets/device-map-2607-pc.png?v=20260509") center / contain no-repeat;
}

.device-map-value {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 0;
  overflow: hidden;
  color: #9cffb0;
  font-size: clamp(18px, 2.2vw, 30px);
  font-weight: 700;
  line-height: 1;
  text-align: center;
  text-shadow: 0 0 8px rgba(156, 255, 176, .42);
}

.device-map-value[data-field="dd1"] {
  left: 17.2%;
  top: 67.9%;
  width: 11.5%;
  height: 7.0%;
}

.device-map-value[data-field="lachizhi"] {
  left: 17.2%;
  top: 37.4%;
  width: 11.5%;
  height: 7.0%;
}

.device-map-value[data-field="lunzhao"] {
  left: 36.3%;
  top: 6.1%;
  width: 11.4%;
  height: 7.1%;
}

.device-map-value[data-field="inlight"] {
  left: 72.4%;
  top: 38.6%;
  width: 11.4%;
  height: 7.1%;
}

.device-map-value[data-field="outlight"] {
  left: 72.4%;
  top: 52.6%;
  width: 11.4%;
  height: 7.1%;
}

.device-map-value[data-field="inside"] {
  left: 72.4%;
  top: 66.4%;
  width: 11.4%;
  height: 7.1%;
}

.device-map-value[data-field="outside"] {
  left: 72.4%;
  top: 80.5%;
  width: 11.4%;
  height: 7.1%;
}

.modal {
  border: 0;
  border-radius: var(--radius);
  width: min(560px, calc(100vw - 28px));
  padding: 0;
}

.modal::backdrop {
  background: rgba(15,23,42,.42);
}

.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.modal-body {
  padding: 16px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  max-width: 340px;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #fff;
  background: #1f2937;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  .auth-page {
    grid-template-columns: 1fr;
    background: var(--bg);
  }

  .auth-panel {
    min-height: 100vh;
    padding: 34px 22px;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .18s ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .topbar,
  .app-main {
    margin-left: 0;
  }

  .topbar {
    padding: 0 14px;
  }

  .topbar .icon-button {
    display: inline-grid;
    place-items: center;
  }

  .app-main {
    padding: 16px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar .input,
  .toolbar button {
    width: 100%;
    max-width: none;
  }

  .device-map {
    max-width: 965px;
    aspect-ratio: 965 / 1277;
    background-image: url("../assets/device-map-2607-mobile.png?v=20260509");
  }

  .device-map-value {
    font-size: clamp(16px, 5.2vw, 28px);
  }

  .device-map-value[data-field="dd1"] {
    left: 5.1%;
    top: 68.0%;
    width: 15.0%;
    height: 7.0%;
  }

  .device-map-value[data-field="lachizhi"] {
    left: 5.1%;
    top: 37.3%;
    width: 15.0%;
    height: 7.1%;
  }

  .device-map-value[data-field="lunzhao"] {
    left: 30.5%;
    top: 6.1%;
    width: 14.9%;
    height: 7.1%;
  }

  .device-map-value[data-field="inlight"] {
    left: 78.3%;
    top: 38.6%;
    width: 15.1%;
    height: 7.1%;
  }

  .device-map-value[data-field="outlight"] {
    left: 78.3%;
    top: 52.8%;
    width: 15.1%;
    height: 7.0%;
  }

  .device-map-value[data-field="inside"] {
    left: 78.3%;
    top: 66.6%;
    width: 15.1%;
    height: 7.1%;
  }

  .device-map-value[data-field="outside"] {
    left: 78.3%;
    top: 80.5%;
    width: 15.1%;
    height: 7.0%;
  }

  .dashboard-table {
    min-width: 0;
  }

  .dashboard-table th,
  .dashboard-table td {
    padding: 10px 8px;
  }

  .dashboard-table .optional-mobile {
    display: none;
  }
}
