* { box-sizing: border-box; }

body {
  min-width: 980px;
  margin: 0;
  color: #edf5ff;
  background:
    linear-gradient(135deg, rgba(9, 14, 26, 0.96), rgba(18, 28, 43, 0.9)),
    linear-gradient(90deg, rgba(76, 189, 183, 0.12) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(148, 163, 184, 0.08) 0 1px, transparent 1px 100%);
  background-size: auto, 42px 42px, 42px 42px;
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
}

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

.app-shell {
  width: min(1220px, calc(100vw - 56px));
  margin: 0 auto;
  padding: 34px 0;
}

.hero,
.workspace,
.panel-title,
.connection-grid,
.actions,
.result-actions,
.device-card,
.management-head,
.management-actions,
.modal-head,
.modal-actions {
  display: flex;
}

.hero {
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  color: #8fc9ff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 12px 0 10px;
  color: #f8fbff;
  font-size: 38px;
  line-height: 1.1;
  letter-spacing: 0;
}

p {
  max-width: 720px;
  margin: 0;
  color: rgba(203, 213, 225, 0.72);
  font-size: 14px;
  line-height: 1.8;
}

.hero-card {
  min-width: 230px;
  padding: 15px 16px;
  border: 1px solid rgba(94, 234, 212, 0.22);
  border-radius: 8px;
  background: rgba(3, 7, 18, 0.48);
}

.hero-card span {
  color: #5eead4;
  font-size: 12px;
  font-weight: 800;
}

.hero-card strong {
  display: block;
  margin-top: 5px;
  color: #f8fbff;
  font-size: 13px;
}

.workspace {
  align-items: stretch;
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 22px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(10, 17, 31, 0.92);
  box-shadow: 0 24px 70px rgba(2, 6, 23, 0.34);
}

.connection-panel,
.management-panel {
  margin-bottom: 18px;
}

.form-panel { flex: 1 1 56%; }
.result-panel { flex: 1 1 44%; }

.panel-title {
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
  color: #dbeafe;
  font-size: 15px;
}

.title-icon,
button svg,
.icon-button svg {
  display: inline-block;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.connection-grid {
  align-items: flex-end;
  gap: 12px;
}

.connection-grid .field {
  flex: 1 1 auto;
}

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

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
}

.field > span {
  color: rgba(226, 232, 240, 0.82);
  font-size: 12px;
  font-weight: 720;
}

.wide { grid-column: 1 / -1; }

input,
select,
textarea {
  width: 100%;
  padding: 0 13px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  outline: none;
  color: #eef4ff;
  background: rgba(3, 7, 18, 0.5);
}

input,
select { height: 38px; }

textarea {
  min-height: 132px;
  padding: 12px 13px;
  line-height: 1.6;
  resize: vertical;
}

input::placeholder,
textarea::placeholder { color: rgba(203, 213, 225, 0.42); }

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(94, 234, 212, 0.54);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.1);
}

.device-card {
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 8px;
  background: rgba(3, 7, 18, 0.34);
}

.device-card strong {
  display: block;
  color: #f8fbff;
  font-size: 13px;
}

.device-card span {
  display: block;
  margin-top: 5px;
  color: rgba(203, 213, 225, 0.66);
  font-size: 12px;
}

.switch {
  position: relative;
  width: 46px;
  height: 24px;
}

.switch input { display: none; }

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.28);
  cursor: pointer;
}

.switch span::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #f8fbff;
  transition: transform 0.16s ease;
}

.switch input:checked + span { background: #2dd4bf; }
.switch input:checked + span::after { transform: translateX(22px); }

.device-input { margin-top: 14px; }
.hidden { display: none; }

.actions,
.result-actions {
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

button {
  height: 38px;
  padding: 0 16px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  color: #dbeafe;
  background: rgba(15, 23, 42, 0.78);
  cursor: pointer;
}

button svg {
  margin-right: 7px;
  vertical-align: -3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.primary-button {
  border-color: #2dd4bf;
  color: #06111c;
  background: #2dd4bf;
  font-weight: 800;
}

.danger-button {
  border-color: rgba(248, 113, 113, 0.78);
  color: #fff1f2;
  background: rgba(190, 18, 60, 0.72);
  font-weight: 800;
}

.ghost-button:hover,
.primary-button:hover,
.danger-button:hover { filter: brightness(1.06); }

.small {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.code-box {
  min-height: 190px;
  padding: 16px;
  overflow: auto;
  border: 1px solid rgba(125, 211, 252, 0.24);
  border-radius: 8px;
  color: #dff7ff;
  background: rgba(3, 7, 18, 0.56);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
}

.code-box.empty {
  border-style: dashed;
  color: rgba(203, 213, 225, 0.4);
}

.payload-card {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.58);
}

.payload-title {
  color: #f8fbff;
  font-size: 13px;
  font-weight: 760;
}

pre {
  max-height: 210px;
  margin: 12px 0 0;
  overflow: auto;
  color: rgba(226, 232, 240, 0.78);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.65;
}

.message {
  min-height: 22px;
  margin-top: 12px;
  color: rgba(203, 213, 225, 0.72);
  font-size: 13px;
}

.message[data-type='success'] { color: #86efac; }
.message[data-type='error'] { color: #fda4af; }

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

.management-head {
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.management-title { margin-bottom: 0; }

.management-title small {
  display: block;
  max-width: 500px;
  margin-top: 5px;
  overflow: hidden;
  color: rgba(203, 213, 225, 0.48);
  font-size: 11px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.management-actions {
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
}

.search-input { width: 260px; }
.status-filter { width: 108px; }

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

.stats-grid > div {
  padding: 13px 14px;
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 8px;
  background: rgba(3, 7, 18, 0.34);
}

.stats-grid span {
  display: block;
  color: rgba(203, 213, 225, 0.62);
  font-size: 12px;
}

.stats-grid strong {
  display: block;
  margin-top: 6px;
  color: #f8fbff;
  font-size: 24px;
  line-height: 1;
}

.table-wrap {
  max-height: 440px;
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 8px;
  background: rgba(3, 7, 18, 0.28);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: rgba(219, 234, 254, 0.78);
  background: rgba(15, 23, 42, 0.98);
  font-size: 12px;
  font-weight: 760;
}

td {
  color: rgba(226, 232, 240, 0.78);
  font-size: 12px;
}

th:nth-child(1) { width: 24%; }
th:nth-child(2) { width: 19%; }
th:nth-child(3) { width: 14%; }
th:nth-child(4) { width: 17%; }
th:nth-child(5) { width: 10%; }
th:nth-child(6) { width: 16%; }

.license-main strong,
.mono-line {
  display: block;
  overflow: hidden;
  color: #f8fbff;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.license-main span,
.muted-line {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  color: rgba(203, 213, 225, 0.55);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mono-line { font-family: Consolas, "SFMono-Regular", monospace; }

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  color: #dbeafe;
  background: rgba(15, 23, 42, 0.72);
  font-size: 11px;
  font-weight: 760;
}

.status-pill.active {
  border-color: rgba(45, 212, 191, 0.34);
  color: #99f6e4;
  background: rgba(13, 148, 136, 0.16);
}

.status-pill.revoked {
  border-color: rgba(248, 113, 113, 0.38);
  color: #fecdd3;
  background: rgba(190, 18, 60, 0.2);
}

.status-pill.expired {
  border-color: rgba(251, 191, 36, 0.34);
  color: #fde68a;
  background: rgba(180, 83, 9, 0.2);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.row-actions button {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.empty-cell {
  height: 96px;
  color: rgba(203, 213, 225, 0.45);
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(2, 6, 23, 0.68);
}

.modal-backdrop.hidden { display: none; }

.modal {
  width: min(560px, calc(100vw - 44px));
  padding: 18px;
  border: 1px solid rgba(125, 211, 252, 0.2);
  border-radius: 8px;
  background: rgba(10, 17, 31, 0.98);
  box-shadow: 0 24px 80px rgba(2, 6, 23, 0.54);
}

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

.modal-head strong {
  color: #f8fbff;
  font-size: 15px;
}

.modal-copy {
  max-width: none;
  margin-bottom: 12px;
  color: rgba(226, 232, 240, 0.72);
}

.icon-button {
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
}

.icon-button svg,
.title-icon svg { margin-right: 0; }

.modal-actions {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 1040px) {
  body { min-width: 0; }
  .workspace,
  .hero,
  .connection-grid { flex-direction: column; }
  .app-shell { width: calc(100vw - 36px); }
  .management-head { flex-direction: column; }
  .management-actions,
  .search-input,
  .status-filter { width: 100%; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
