.qbc-wm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.qbc-wm-dialog {
  display: flex;
  flex-direction: column;
  width: min(960px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 18px;
  background: #f8fafc;
  box-shadow: 0 30px 70px rgba(15, 23, 42, 0.28);
}

.qbc-wm-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px;
  background: linear-gradient(120deg, #0ea5e9, #6366f1);
  color: #fff;
  border-radius: 18px 18px 0 0;
}

.qbc-wm-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.qbc-wm-subtitle {
  margin: 6px 0 0;
  font-size: 12px;
  opacity: 0.88;
}

.qbc-wm-close {
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  width: 30px;
  height: 30px;
  font-size: 14px;
  cursor: pointer;
}

.qbc-wm-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

.qbc-wm-message {
  margin: 14px 22px 0;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
  background: #eff6ff;
  color: #1d4ed8;
}

.qbc-wm-message[data-tone="ok"] {
  background: #ecfdf5;
  color: #047857;
}

.qbc-wm-message[data-tone="warn"] {
  background: #fffbeb;
  color: #b45309;
}

.qbc-wm-message[data-tone="error"] {
  background: #fef2f2;
  color: #b91c1c;
}

.qbc-wm-loading {
  padding: 40px 22px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
}

.qbc-wm-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 22px 0;
}

.qbc-wm-select,
.qbc-wm-input,
.qbc-wm-textarea,
.qbc-wm-key {
  border: 1px solid #d7dee8;
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
}

.qbc-wm-select {
  min-width: 220px;
}

.qbc-wm-select.small {
  min-width: 130px;
}

.qbc-wm-select:focus,
.qbc-wm-input:focus,
.qbc-wm-textarea:focus,
.qbc-wm-key:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.qbc-wm-textarea {
  width: 100%;
  resize: vertical;
  line-height: 1.6;
  font-family: inherit;
}

.qbc-wm-btn {
  border: 1px solid #d7dee8;
  border-radius: 10px;
  background: #fff;
  color: #334155;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
}

.qbc-wm-btn:hover {
  background: #f1f5f9;
}

.qbc-wm-btn.primary {
  border-color: transparent;
  background: linear-gradient(120deg, #2563eb, #4f46e5);
  color: #fff;
}

.qbc-wm-btn.primary:hover {
  filter: brightness(1.06);
}

.qbc-wm-btn.small {
  padding: 5px 10px;
  font-size: 11.5px;
}

.qbc-wm-btn.danger {
  border-color: #fecaca;
  color: #b91c1c;
  background: #fef2f2;
}

.qbc-wm-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.qbc-wm-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 22px 0;
}

.qbc-wm-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  padding: 10px 14px;
}

.qbc-wm-stat strong {
  font-size: 18px;
  color: #0f172a;
}

.qbc-wm-stat span {
  font-size: 11.5px;
  color: #64748b;
}

.qbc-wm-rank {
  margin: 12px 22px 0;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  padding: 12px 14px;
}

.qbc-wm-rank h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #0f172a;
}

.qbc-wm-rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  font-size: 12px;
  color: #475569;
}

.qbc-wm-rank-row strong {
  color: #0f172a;
  font-weight: 600;
}

.qbc-wm-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 22px 22px;
}

.qbc-wm-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qbc-wm-field-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: #334155;
}

.qbc-wm-hint {
  font-size: 11px;
  font-weight: 400;
  color: #94a3b8;
}

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

.qbc-wm-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  padding: 12px 14px;
  cursor: pointer;
}

.qbc-wm-switch-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.qbc-wm-switch-copy strong {
  font-size: 13px;
  color: #0f172a;
}

.qbc-wm-switch-copy span {
  font-size: 11.5px;
  color: #64748b;
}

.qbc-wm-switch-control {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 24px;
  flex: none;
}

.qbc-wm-switch-control input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.qbc-wm-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.18s ease;
}

.qbc-wm-switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
}

.qbc-wm-switch-control input:checked + .qbc-wm-switch-track {
  background: #4f46e5;
}

.qbc-wm-switch-control input:checked + .qbc-wm-switch-track::after {
  transform: translateX(18px);
}

.qbc-wm-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qbc-wm-item {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qbc-wm-item-head {
  display: flex;
  gap: 8px;
  align-items: center;
}

.qbc-wm-key {
  width: 42px;
  text-align: center;
  font-weight: 700;
}

.qbc-wm-item-head .qbc-wm-input {
  flex: 1;
  min-width: 0;
}

.qbc-wm-preview {
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: #f8fbff;
  padding: 12px 14px;
}

.qbc-wm-preview h4 {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: #1d4ed8;
}

.qbc-wm-preview-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12.5px;
  line-height: 1.7;
  color: #334155;
  font-family: inherit;
}

.qbc-wm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

html[data-theme="dark"] .qbc-wm-dialog {
  background: #0f172a;
}

html[data-theme="dark"] .qbc-wm-stat,
html[data-theme="dark"] .qbc-wm-switch,
html[data-theme="dark"] .qbc-wm-item,
html[data-theme="dark"] .qbc-wm-preview,
html[data-theme="dark"] .qbc-wm-rank {
  background: #111c31;
  border-color: #1f2a44;
}

html[data-theme="dark"] .qbc-wm-stat strong,
html[data-theme="dark"] .qbc-wm-switch-copy strong,
html[data-theme="dark"] .qbc-wm-field-label,
html[data-theme="dark"] .qbc-wm-preview-body,
html[data-theme="dark"] .qbc-wm-rank h4,
html[data-theme="dark"] .qbc-wm-rank-row strong {
  color: #e2e8f0;
}

html[data-theme="dark"] .qbc-wm-rank-row {
  color: #94a3b8;
}

html[data-theme="dark"] .qbc-wm-input,
html[data-theme="dark"] .qbc-wm-textarea,
html[data-theme="dark"] .qbc-wm-select,
html[data-theme="dark"] .qbc-wm-key,
html[data-theme="dark"] .qbc-wm-btn {
  background: #0b1526;
  border-color: #26344f;
  color: #e2e8f0;
}

html[data-theme="dark"] .qbc-wm-btn.primary {
  background: linear-gradient(120deg, #2563eb, #4f46e5);
  color: #fff;
}

@media (max-width: 720px) {
  .qbc-wm-stats,
  .qbc-wm-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .qbc-wm-item-head {
    flex-wrap: wrap;
  }
}
