:root {
  --gold: #c8a45c;
  --gold-light: #f5efe6;
  --navy: #0d0d0d;
  --navy-light: #1a1a1a;
  --bg: #111;
  --bg-card: #1a1a1a;
  --bg-input: #151515;
  --text: #e0d8cc;
  --text-muted: #8a8078;
  --border: #2a2520;
  --border-light: #3a3530;
  --radius: 10px;
  --radius-sm: 6px;
  --error: #c0392b;
  --font:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* 登录 */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 28px;
  width: 380px;
  max-width: 90vw;
}
.auth-logo {
  text-align: center;
  margin-bottom: 24px;
}
.auth-logo .icon {
  font-size: 36px;
  color: var(--gold);
  margin-bottom: 8px;
}
.auth-logo h2 {
  font-size: 20px;
  color: var(--text);
  letter-spacing: 1px;
}
.auth-logo p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.auth-tabs {
  display: flex;
  margin-bottom: 20px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.auth-tab {
  flex: 1;
  padding: 9px;
  border: none;
  background: 0 0;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 4px;
  transition: all 0.2s;
  font-weight: 500;
}
.auth-tab.active {
  background: var(--gold);
  color: var(--navy);
}
.auth-error {
  color: var(--error);
  font-size: 11px;
  margin-top: 4px;
  min-height: 16px;
}
.auth-success {
  color: var(--gold);
  font-size: 11px;
  margin-top: 4px;
  min-height: 16px;
}

/* 弹层 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}
.lightbox-overlay {
  z-index: 1200;
}
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 380px;
  max-width: 90vw;
}
.modal-card h3 {
  font-size: 15px;
  margin-bottom: 14px;
  color: var(--gold);
}
.alert-card {
  text-align: center;
  padding: 36px 24px 28px;
}
.alert-icon {
  font-size: 44px;
  margin-bottom: 10px;
  color: var(--gold);
}
.alert-card h3 {
  font-size: 14px;
  margin-bottom: 20px;
  color: var(--text);
}
.alert-card .modal-btns {
  justify-content: center;
  gap: 10px;
}
.alert-card .btn-primary,
.alert-card .btn-outline {
  width: auto;
  padding: 9px 28px;
}
.modal-btns {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.history-modal-card {
  width: min(760px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
}
.modal-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.modal-title-row h3 {
  margin-bottom: 0;
}
.history-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

/* 主应用 */
.app {
  max-width: 1340px;
  margin: 0 auto;
  padding: 0 20px 28px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  margin-bottom: 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-brand {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 1px;
}
.topbar-brand span {
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 2px;
  margin-left: 6px;
  text-transform: uppercase;
}
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}
.credits-badge {
  background: var(--gold);
  color: var(--navy);
  padding: 4px 12px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 12px;
}
.btn-outline-white {
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  background: 0 0;
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-outline-white:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.main {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.panel {
  width: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 卡片 */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card h3 {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--gold);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* 输入 */
label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
  margin-top: 8px;
}
label:first-of-type {
  margin-top: 0;
}
input[type="text"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-input);
  color: var(--text);
  outline: 0;
  font-family: var(--font);
  transition: border-color 0.2s;
}
input:focus,
textarea:focus {
  border-color: var(--gold);
}
textarea {
  resize: vertical;
  min-height: 56px;
}

/* 按钮组 */
.btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-opt {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}
.btn-opt.active {
  background: var(--gold);
  color: var(--navy);
  border-color: var(--gold);
  font-weight: 600;
}
.btn-opt:hover:not(.active) {
  border-color: var(--gold);
  color: var(--text);
}

/* 手术卡片单选 */
.proc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.proc-card {
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font);
  font-weight: 500;
  line-height: 1.3;
}
.proc-card .icon {
  display: block;
  font-size: 18px;
  margin-bottom: 4px;
}
.proc-card.selected {
  background: rgba(200, 164, 92, 0.12);
  border-color: var(--gold);
  color: var(--gold);
  font-weight: 600;
  box-shadow: 0 0 12px rgba(200, 164, 92, 0.08);
}
.proc-card:hover:not(.selected) {
  border-color: var(--border-light);
  color: var(--text);
}

/* 上传 */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
}
.upload-zone:hover {
  border-color: var(--gold);
  background: rgba(200, 164, 92, 0.03);
}
.upload-zone.dragover {
  border-color: var(--gold);
  background: rgba(200, 164, 92, 0.05);
}
.upload-icon {
  font-size: 32px;
  color: var(--gold);
  font-weight: 200;
  margin-bottom: 4px;
}
.upload-zone p {
  font-size: 12px;
  color: var(--text-muted);
}
.upload-zone .hint {
  font-size: 10px;
  margin-top: 2px;
  opacity: 0.6;
}
.preview-wrap {
  position: relative;
  margin-top: 10px;
}
.preview-wrap img {
  width: 100%;
  max-height: 160px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* 下拉 */
.dropdown {
  position: relative;
}
.dropdown-trigger {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  position: relative;
}
.dropdown-trigger::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: translateY(-70%) rotate(45deg);
  transition: transform 0.2s;
}
.dropdown.open .dropdown-trigger::after {
  transform: translateY(-30%) rotate(-135deg);
}
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 180px;
  overflow-y: auto;
  z-index: 50;
  padding: 4px;
}
.dropdown.open .dropdown-menu {
  display: block;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}
.dropdown-item:hover {
  background: rgba(200, 164, 92, 0.04);
}
.dropdown-item input[type="checkbox"] {
  accent-color: var(--gold);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* 按钮 */
.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--gold);
  color: var(--navy);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.25s;
  font-family: var(--font);
}
.btn-primary:hover {
  filter: brightness(1.1);
}
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-outline {
  width: 100%;
  padding: 10px;
  background: 0 0;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}
.btn-outline:hover {
  border-color: var(--gold);
}
.btn-sm {
  padding: 5px 12px;
  font-size: 10px;
  background: 0 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
  font-family: var(--font);
  margin-top: 6px;
}
.btn-sm:hover {
  border-color: var(--gold);
}

/* 结果 */
.result-area {
  flex: 1;
  min-height: 300px;
}
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.result-grid.single {
  grid-template-columns: 1fr;
  max-width: 400px;
  margin: 0 auto;
}
.placeholder {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.placeholder-icon {
  font-size: 44px;
  margin-bottom: 10px;
  opacity: 0.2;
}
.placeholder p {
  font-size: 13px;
  opacity: 0.5;
}
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.result-card:hover {
  border-color: var(--gold);
}
.result-card img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  cursor: pointer;
  display: block;
}
.result-card .label {
  padding: 10px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  background: var(--bg-input);
  color: var(--gold);
  border-top: 1px solid var(--border);
}
.result-card .label.error {
  color: var(--error);
}
.download-link {
  display: block;
  text-align: center;
  padding: 8px;
  font-size: 10px;
  color: var(--text-muted);
  text-decoration: none;
  border-top: 1px solid var(--border);
  transition: color 0.2s;
}
.download-link:hover {
  color: var(--gold);
}

/* 加载 */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.06);
  }
}
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}
.loading-icon {
  display: inline-block;
  width: 44px;
  height: 44px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation:
    spin 0.8s linear infinite,
    pulse 2s ease-in-out infinite;
  margin-bottom: 14px;
}
.loading-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--gold);
  letter-spacing: 1px;
}
.loading-dots::after {
  content: "";
  animation: dots 2s steps(1) infinite;
}
@keyframes dots {
  0%,
  20% {
    content: "";
  }
  40% {
    content: ".";
  }
  60% {
    content: "..";
  }
  80%,
  100% {
    content: "...";
  }
}

/* 历史 */
.history-section {
  margin-top: 24px;
}
.history-section h3 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--gold);
}
.history-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 12px;
}
.history-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  background: var(--bg-input);
  border-bottom: 1px solid var(--border);
}
.history-table td {
  padding: 10px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.history-table tr:hover td {
  background: rgba(200, 164, 92, 0.03);
}
.tag {
  display: inline-block;
  padding: 1px 7px;
  background: var(--gold);
  color: var(--navy);
  border-radius: 3px;
  font-size: 10px;
  margin: 1px;
  font-weight: 600;
}
.stages-tags {
  background: var(--navy-light);
  color: var(--gold);
  border: 1px solid var(--gold);
}
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.pagination button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
  font-family: var(--font);
}
.pagination button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.pagination button:hover:not(:disabled) {
  border-color: var(--gold);
}
.empty-state {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 12px;
}

/* 日志 */
.log-panel {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.log-header h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
}
.log-body {
  background: #0a0a0a;
  color: #888;
  font-family: "SF Mono", Menlo, Monaco, monospace;
  font-size: 10px;
  padding: 12px 16px;
  max-height: 150px;
  overflow-y: auto;
  line-height: 1.6;
}

/* 响应式 */
/* genkey */
.genkey-page {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 28px;
}
.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.admin-card h3 {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--gold);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.key-list {
  font-family: "SF Mono", Menlo, monospace;
}
.key-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 5px;
  font-size: 13px;
}
.key-item code {
  color: var(--gold);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.5px;
}
.key-credits {
  color: var(--gold);
  font-weight: 600;
  font-size: 12px;
}
.record-item {
  display: grid;
  grid-template-columns: 1fr 50px 50px 130px;
  gap: 8px;
  align-items: center;
  padding: 7px 10px;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
}
.record-item code {
  color: var(--text-muted);
  font-size: 10px;
}
.record-item .used {
  color: var(--gold);
  font-weight: 600;
}
.record-item .unused {
  color: var(--text-muted);
}

/* V7 极简布局 */
.main-v7 {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.upload-card {
  text-align: center;
}
.upload-card .upload-zone {
  max-width: 400px;
  margin: 0 auto;
}
.upload-card .preview-wrap {
  max-width: 260px;
  margin: 10px auto 0;
}
.options-card {
  text-align: center;
}
.options-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.option-group {
  flex: 0 1 132px;
}
.option-group label {
  font-size: 11px;
  color: var(--text-muted);
  text-align: left;
  margin-bottom: 4px;
}
.option-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-input);
  color: var(--text);
  outline: 0;
  font-family: var(--font);
  cursor: pointer;
}
.option-group select:focus {
  border-color: var(--gold);
}
.toggle-group {
  display: flex;
  gap: 16px;
  align-items: center;
  padding-bottom: 4px;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
}
.toggle-label input[type="checkbox"] {
  accent-color: var(--gold);
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.result-card-main {
  text-align: center;
}
.result-single {
  max-width: 400px;
  margin: 0 auto;
}
.result-single img {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
}
.result-single .label {
  padding: 8px;
  font-size: 12px;
  color: var(--gold);
}
.result-single .download-link {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 16px;
  border: 1px solid var(--gold);
  border-radius: 16px;
  color: var(--gold);
  text-decoration: none;
  font-size: 12px;
  transition: all 0.2s;
}
.result-single .download-link:hover {
  background: var(--gold);
  color: var(--navy);
}
.options-card .btn-primary {
  max-width: 300px;
  margin: 0 auto;
}

@media (max-width: 960px) {
  .main {
    flex-direction: column;
  }
  .panel {
    width: 100%;
  }
  .result-grid {
    grid-template-columns: 1fr;
  }
  .proc-grid {
    grid-template-columns: 1fr 1fr;
  }
}
