:root {
  color-scheme: light;
  --ink: #111418;
  --muted: #66717f;
  --line: #d7dde5;
  --paper: #f6f2ea;
  --panel: #fffdf8;
  --accent: #0f766e;
  --accent-dark: #0b4f4a;
  --danger: #a83232;
  --shadow: 0 18px 45px rgba(26, 32, 44, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(15, 118, 110, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 36px 36px;
  font-family: ui-sans-serif, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 18px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tabs {
  display: inline-flex;
  gap: 6px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: #fff;
  padding: 4px;
}

.tab {
  min-height: 34px;
  border: 0;
  border-radius: 3px;
  padding: 0 12px;
  background: transparent;
  color: var(--ink);
}

.tab.active {
  background: var(--ink);
  color: #fff;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1;
}

h2 {
  font-size: 18px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.auth-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 160px;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.auth-strip span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.summary-strip div {
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: #ffffff;
  padding: 12px;
}

.summary-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-strip strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.grid {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 2px solid var(--ink);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.devices {
  min-height: 480px;
}

.detail {
  min-height: 260px;
}

.logs {
  min-height: 260px;
}

.device-list,
.log-list {
  display: grid;
  gap: 10px;
}

.log-list {
  min-height: 430px;
  align-content: start;
}

.device {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 5px;
  padding: 12px;
  cursor: pointer;
}

.device.selected {
  border-color: var(--accent);
  outline: 2px solid rgba(15, 118, 110, 0.18);
}

.device strong,
.log strong {
  display: block;
  font-size: 14px;
}

.device span,
.log span,
.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.status {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.status.online {
  color: #0b5d38;
  border-color: #0b5d38;
}

.status.muted {
  color: var(--muted);
}

.actions {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

button {
  min-height: 42px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.95);
}

button.ghost {
  background: transparent;
  color: var(--ink);
}

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

button.small {
  min-height: 34px;
  border-width: 1px;
  padding: 0 12px;
}

.button-link {
  display: inline-grid;
  min-height: 42px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  padding: 0 14px;
  text-decoration: none;
}

.message-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 10px;
  margin-top: 12px;
}

input {
  min-height: 42px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  padding: 0 12px;
  font: inherit;
  background: #fff;
}

textarea {
  min-height: 110px;
  resize: vertical;
  border: 2px solid var(--ink);
  border-radius: 5px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

.policy-box {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.policy-box label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.help-text {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.log {
  border-left: 4px solid var(--accent);
  background: #ffffff;
  border-radius: 4px;
  padding: 10px 12px;
}

.list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.pager {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pager button {
  min-height: 32px;
  border-width: 1px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

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

.dialog-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
}

.dialog-root.open {
  display: block;
}

.dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 20, 24, 0.58);
}

.dialog-panel {
  position: relative;
  width: min(440px, calc(100vw - 32px));
  margin: 10vh auto 0;
  border: 1px solid rgba(17, 20, 24, 0.12);
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: 0 24px 70px rgba(17, 20, 24, 0.26);
  padding: 20px;
}

.dialog-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.dialog-description {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

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

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

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.dialog-actions button {
  min-width: 82px;
}

.dialog-actions .ghost {
  background: #fff;
}

.management {
  min-height: 520px;
}

.provisioner-download,
.default-policy,
.usb-provision {
  margin-bottom: 16px;
}

.toggle-row {
  display: inline-grid;
  grid-template-columns: 18px auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.toggle-row input {
  min-height: auto;
  padding: 0;
}

.flow-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.flow-steps span {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  padding: 12px;
}

.provision-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 10px;
}

.usb-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.usb-device {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  padding: 10px 12px;
}

.usb-device input {
  min-height: auto;
  padding: 0;
}

.usb-device strong,
.usb-device em {
  display: block;
}

.usb-device em,
.muted-line,
.error-line,
.provision-item span {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.error-line {
  color: var(--danger);
}

.provision-result {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.provision-item {
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  background: #fff;
  padding: 10px 12px;
}

.provision-item.failed {
  border-left-color: var(--danger);
}

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

.device-table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
}

.device-table th,
.device-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.device-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.device-table td strong,
.device-table td span {
  display: block;
}

.device-table td span {
  color: var(--muted);
  line-height: 1.5;
}

.device-table code {
  display: block;
  width: fit-content;
  margin: 0 0 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  background: #f7faf9;
  color: var(--accent-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.empty-cell {
  color: var(--muted);
  text-align: center !important;
  padding: 44px 12px !important;
}

@media (max-width: 820px) {
  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-strip {
    grid-template-columns: 1fr;
  }

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

  .actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .flow-steps {
    grid-template-columns: 1fr;
  }
}
