:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --text: #172033;
  --muted: #667085;
  --border: #d9e1ea;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --ok: #168a5b;
  --danger: #c2410c;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

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

button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

code {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  color: #24324a;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: #111827;
  color: #fff;
  padding: 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand strong {
  display: block;
  font-size: 16px;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: #aeb8c7;
  font-size: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.sidebar a {
  color: #c8d1df;
  text-decoration: none;
  border-radius: 6px;
  padding: 11px 12px;
  font-size: 14px;
  font-weight: 600;
}

.sidebar a.active,
.sidebar a:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.sidebar form {
  margin-top: auto;
}

.workspace {
  padding: 28px;
}

.topbar,
.section-head,
.button-row,
.two-col {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.primary:hover {
  background: var(--accent-strong);
}

.ghost {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

.ghost:hover {
  background: var(--surface-2);
}

.full {
  width: 100%;
}

.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.warning {
  margin-bottom: 16px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  padding: 12px 14px;
  font-size: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stats-grid.wide {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stats-grid article,
.table-panel,
.detail-panel,
.log-panel,
.login-panel,
.dialog-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stats-grid article {
  padding: 16px;
}

.stats-grid span {
  color: var(--muted);
  font-size: 13px;
}

.stats-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.manager-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
  align-items: start;
  margin-bottom: 18px;
}

.manager-table {
  min-height: 430px;
}

.manager-side {
  display: grid;
  gap: 10px;
}

.side-box {
  display: grid;
  gap: 10px;
  border: 1px solid #cfd6df;
  border-radius: 4px;
  background: #edf0f3;
  padding: 12px;
}

.side-box h3 {
  margin: 0;
  color: #174ea6;
  font-size: 15px;
}

.side-box label {
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: #1f2937;
  font-size: 14px;
}

.side-box input,
.side-box select {
  min-height: 34px;
  border-radius: 2px;
  padding: 7px 8px;
}

.tab-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid #cfd6df;
}

.tab-strip .tab,
.tab-strip a {
  min-height: 32px;
  border-radius: 0;
  background: #f8fafc;
  color: #111827;
  text-align: center;
  text-decoration: none;
  padding: 7px 6px;
  font-size: 13px;
  font-weight: 700;
}

.tab-strip .active {
  border-top: 2px solid #2563eb;
  background: #fff;
  color: #174ea6;
}

.radio-line {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px !important;
  font-weight: 500;
}

.radio-line input {
  width: auto;
  min-height: auto;
}

.search-button {
  justify-self: end;
  min-width: 88px;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid #cfd6df;
  border-radius: 4px;
  background: #fff;
  color: #8b2bb1;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.tool-button:hover {
  background: #f4f7fb;
}

.classic-table th,
.classic-table td {
  border: 1px solid #e5e7eb;
  padding: 7px 8px;
  font-size: 13px;
}

.classic-table th {
  background: #eef0f2;
  color: #1f2937;
  font-size: 13px;
}

.classic-table th.sortable-header {
  cursor: pointer;
  user-select: none;
}

.classic-table th.sortable-header:hover,
.classic-table th.sortable-header.sorted {
  background: #dbeafe;
  color: #174ea6;
}

.classic-table tbody tr {
  height: 30px;
}

.classic-table .check-cell {
  width: 34px;
  text-align: center;
}

.classic-table input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
  padding: 0;
}

.expand-company {
  width: 22px;
  min-height: 22px;
  padding: 0;
  margin-right: 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
  color: #1f2937;
  line-height: 1;
}

.expand-company:hover {
  background: #eef5ff;
  border-color: var(--accent);
}

.company-device-row {
  cursor: default;
  background: #f8fbff;
}

.company-device-row:hover {
  background: #f8fbff;
}

.company-device-panel {
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid #dbeafe;
  border-radius: 6px;
  background: #fff;
}

.company-device-panel strong {
  color: #172033;
  font-size: 13px;
}

.company-device-panel span,
.company-device-panel small {
  color: var(--muted);
  font-size: 12px;
}

.company-device-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.company-device-list div {
  display: grid;
  gap: 3px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 7px 8px;
  background: #f8fafc;
}

.company-device-table-wrap {
  max-height: 260px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
}

.company-device-table {
  min-width: 1420px;
  font-size: 12px;
}

.company-device-table th,
.company-device-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #edf2f7;
}

.company-device-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
}

.company-device-table code {
  color: #334155;
  font-size: 12px;
}

.device-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  border-radius: 999px;
  padding: 3px 8px;
  font-weight: 700;
  font-size: 12px;
}

.device-state.online {
  color: #047857;
  background: #dcfce7;
}

.device-state.offline {
  color: #475569;
  background: #e2e8f0;
}

.device-state.disabled {
  color: #b91c1c;
  background: #fee2e2;
}

.device-note-editor {
  display: flex;
  align-items: center;
  gap: 6px;
}

.device-note-editor input {
  min-width: 130px;
  min-height: 30px;
  padding: 5px 7px;
  font-size: 12px;
}

.muted-text {
  color: var(--muted);
  font-size: 12px;
}

.wide-detail {
  grid-column: 1 / -1;
  position: static;
}

.content-grid.equal {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-top: 18px;
}

.table-panel,
.detail-panel,
.log-panel {
  overflow: hidden;
}

.section-head {
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 15px 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 16px;
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
}

.section-head input {
  max-width: 280px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 13px 16px;
  text-align: left;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

td strong {
  display: block;
}

td span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #eef5ff;
}

.detail-panel {
  position: sticky;
  top: 24px;
}

.detail-form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.two-col {
  gap: 10px;
}

.two-col label {
  flex: 1;
}

.button-row {
  gap: 10px;
}

.status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
}

.status.ok {
  background: #dcfce7;
  color: #166534;
}

.status.danger {
  background: #ffedd5;
  color: var(--danger);
}

.status.muted {
  background: #eef2f7;
  color: #667085;
}

.device-list {
  border-top: 1px solid var(--border);
  padding: 15px 16px;
}

.device-list h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.device-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px;
  margin-bottom: 10px;
}

.device-item span,
.device-item code {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.log-panel {
  margin-top: 18px;
}

.log-panel.compact {
  margin-top: 0;
}

.check-list {
  display: grid;
}

.scroll-list {
  max-height: 360px;
  overflow-y: auto;
}

.scroll-list::-webkit-scrollbar {
  width: 10px;
}

.scroll-list::-webkit-scrollbar-thumb {
  background: #c6d3e4;
  border-radius: 999px;
  border: 2px solid var(--surface);
}

.scroll-list::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.check-row {
  display: grid;
  grid-template-columns: 86px 220px minmax(0, 1fr) 170px;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 11px 16px;
  font-size: 13px;
}

.check-row small {
  color: var(--muted);
}

.empty {
  color: var(--muted);
  padding: 18px 16px;
  font-size: 14px;
}

.settings-form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.settings-form .hint,
.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.dll-upload-list {
  display: grid;
  gap: 10px;
}

.dll-upload-list label {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 10px;
}

.dll-upload-list span {
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
}

.dll-upload-list input {
  grid-column: 1 / -1;
}

.target-panel {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.target-panel legend {
  color: var(--text);
  font-weight: 700;
  padding: 0 4px;
}

.target-check-list {
  display: grid;
  gap: 8px;
  max-height: 190px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.target-check-list::-webkit-scrollbar {
  width: 10px;
}

.target-check-list::-webkit-scrollbar-thumb {
  background: #c6d3e4;
  border-radius: 999px;
  border: 2px solid #f8fafc;
}

.target-check-list::-webkit-scrollbar-track {
  background: #eef4fb;
}

.target-check-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid #dbe4ef;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.target-check-item input {
  width: auto;
}

.target-check-item span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.target-check-item strong,
.target-check-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.target-check-item strong {
  color: var(--text);
  font-size: 14px;
}

.target-check-item small {
  color: var(--muted);
  font-size: 12px;
}

.empty-target {
  padding: 12px;
  color: var(--muted);
  font-size: 14px;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.check-line input {
  width: auto;
}

.feature-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.feature-panel strong {
  display: block;
  font-size: 14px;
}

.feature-panel span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.switch-line {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #1f2937;
  font-size: 14px;
  font-weight: 700;
}

.switch-line input {
  width: 18px;
  min-height: 18px;
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.usage-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.usage-card strong {
  font-size: 14px;
}

.usage-card span,
.usage-card small {
  color: var(--muted);
  font-size: 12px;
}

.usage-card div {
  font-size: 18px;
  font-weight: 800;
}

.mini-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.mini-stats span {
  border-radius: 999px;
  background: #eef2f7;
  color: #344054;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

dialog {
  border: 0;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.dialog-card {
  display: grid;
  gap: 12px;
  width: min(520px, calc(100vw - 32px));
  padding: 0 16px 16px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  min-height: 34px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
}

.login-page {
  display: grid;
  place-items: center;
  background: #eef3f8;
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel {
  display: grid;
  gap: 16px;
  padding: 28px;
}

.login-panel h1 {
  margin: 0;
  font-size: 24px;
}

.login-panel p {
  margin: 0;
  color: var(--muted);
}

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

.login-error {
  display: none;
  color: var(--danger);
  font-size: 13px;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .content-grid,
  .manager-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid.wide,
  .content-grid.equal,
  .usage-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }

  .check-row {
    grid-template-columns: 1fr;
  }
}
