:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-secondary: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #059669;
  --error: #dc2626;
  --warning: #d97706;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.app { min-height: 100vh; }

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
}

.brand h1 { font-size: 18px; font-weight: 600; }
.brand p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.stat-badge {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 20px;
  background: #eff6ff;
  color: #1e40af;
  white-space: nowrap;
}

.stat-badge b {
  font-size: 15px;
  margin: 0 2px;
}

.env-badge {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 20px;
  background: #f3f4f6;
  color: var(--text-secondary);
  white-space: nowrap;
}

.env-badge.ready { background: #ecfdf5; color: var(--success); }
.env-badge.error { background: #fef2f2; color: var(--error); }

.header-actions { display: flex; align-items: center; gap: 10px; }

.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
  text-align: center;
}

.login-card h1 { font-size: 20px; margin-top: 12px; }
.login-sub { font-size: 13px; color: var(--text-secondary); margin: 6px 0 24px; }

.brand-icon.lg {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  font-size: 24px;
  border-radius: 14px;
}

.login-card .field { text-align: left; margin-bottom: 14px; }
.login-error { color: var(--error); font-size: 13px; margin-bottom: 12px; }
.login-error.hidden { display: none; }

.queue-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
}

.queue-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 10px; }

.queue-stats {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.queue-stats b { color: var(--text); font-size: 18px; margin-left: 4px; }

.field input[type="file"] {
  display: none;
}

.upload-field {
  display: flex;
  align-items: center;
  gap: 12px;
}

.upload-preview {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  border: 1px dashed var(--border);
  background: #f9fafb;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.upload-preview.has-image {
  border-style: solid;
  background: #fff;
}

.upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-placeholder {
  font-size: 10px;
  color: var(--text-secondary);
  text-align: center;
  padding: 4px;
  line-height: 1.3;
}

.upload-preview.has-image .upload-placeholder { display: none; }

.upload-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-xs {
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
}

.upload-clear { color: var(--error); }

.timezone-field {
  display: flex;
  gap: 8px;
}

.timezone-field input {
  flex: 1;
  min-width: 0;
}

.timezone-quick {
  width: 88px;
  height: 40px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}

.timezone-quick:focus {
  outline: none;
  border-color: var(--primary);
}

.screenshots-field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.screenshots-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 0;
}

.screenshots-grid:empty::before {
  content: '最多 5 张，用于落地页轮播';
  font-size: 12px;
  color: var(--text-secondary);
}

.screenshot-item {
  position: relative;
  width: 80px;
  height: 142px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f9fafb;
}

.screenshot-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.screenshot-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screenshot-remove:hover { background: rgba(0,0,0,.75); }

.result-link-copy {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.result-link-copy a {
  flex: 1;
  min-width: 0;
  color: var(--primary);
}

.btn-copy {
  flex-shrink: 0;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
}

.btn-copy:hover { background: #f9fafb; color: var(--text); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #111827;
  color: #fff;
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 200;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-rows: auto auto;
  gap: 24px;
  align-items: start;
}

.main > .form-card:not(.adjust-form-card) {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

.main > .adjust-form-card {
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
}

.main > .side-panel {
  grid-column: 2;
  grid-row: 1 / -1;
}

.form-card, .result-card, .history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form-card { padding: 28px; }

.adjust-form-card {
  border-color: #c7d2fe;
  box-shadow: 0 1px 3px rgba(37,99,235,.08), 0 4px 16px rgba(37,99,235,.06);
}

.adjust-form-card .form-section h2 {
  color: #1e40af;
}

.adjust-intro { margin-bottom: 12px; }

.adjust-token-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.adjust-token-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: #1e40af;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0;
}

.adjust-token-bulk {
  margin-bottom: 14px;
}

.adjust-token-bulk-input {
  width: 100%;
  min-height: 108px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.55;
  font-family: ui-monospace, Consolas, monospace;
  resize: vertical;
  box-sizing: border-box;
}

.adjust-token-bulk-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.btn-adjust {
  background: #1e40af;
}

.btn-adjust:hover:not(:disabled) {
  background: #1e3a8a;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  font-size: 13px;
  color: var(--text-secondary);
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

.adjust-landing-toggle {
  margin-bottom: 0;
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.adjust-landing-toggle input {
  width: 16px;
  height: 16px;
}

.adjust-sandbox-field .checkbox-row {
  height: auto;
  min-height: 40px;
}

.result-share {
  margin-top: 16px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f9fafb;
  overflow: hidden;
}

.result-share + .result-share {
  margin-top: 8px;
}

.result-share.hidden { display: none; }

.result-share-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.result-share-head span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.result-share pre {
  margin: 0;
  padding: 12px;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  max-height: 220px;
  overflow-y: auto;
}

.history-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #eff6ff;
  color: #1e40af;
  margin-left: 4px;
}

.form-section + .form-section {
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.form-section h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }

.adjust-token-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 16px;
}

@media (max-width: 900px) {
  .adjust-token-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .adjust-token-grid { grid-template-columns: 1fr; }
}

.field span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.field em { color: var(--error); font-style: normal; }

.field-note {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.adjust-package-notice {
  grid-column: 1 / -1;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  font-size: 12px;
  color: #1e3a8a;
  line-height: 1.55;
}

.adjust-package-notice strong {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
  color: #1e40af;
}

.adjust-package-notice p {
  margin: 0 0 6px;
}

.adjust-package-notice ul {
  margin: 0 0 6px;
  padding-left: 18px;
}

.adjust-package-notice li {
  margin-bottom: 2px;
}

.adjust-package-notice code {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255,255,255,.7);
}

.adjust-package-notice-tip {
  margin-bottom: 0 !important;
  color: #2563eb;
}

.field input,
.field select {
  width: 100%;
  max-width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.field input::placeholder { color: #9ca3af; }

.field-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  line-height: 1.5;
}

.result-links {
  margin: 14px 0;
  text-align: left;
  font-size: 12px;
}

.result-link-row {
  margin-bottom: 8px;
  word-break: break-all;
}

.result-link-row span {
  display: block;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.result-link-row a { color: var(--primary); }

.form-actions {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn {
  height: 42px;
  padding: 0 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, opacity .15s;
  text-decoration: none;
}

.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: #f9fafb; }

.btn-block { width: 100%; margin-top: 16px; }

.side-panel { display: flex; flex-direction: column; gap: 16px; }

.result-card {
  padding: 24px;
  text-align: center;
}

.result-card.hidden { display: none; }

.result-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.result-icon.success { background: #ecfdf5; color: var(--success); }
.result-icon.error { background: #fef2f2; color: var(--error); }
.result-icon.building { background: #eff6ff; color: var(--primary); }

.result-card h3 { font-size: 16px; margin-bottom: 6px; }
.result-card p { font-size: 13px; color: var(--text-secondary); word-break: break-word; }

.history-card { padding: 20px; }

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.history-header h3 { font-size: 14px; font-weight: 600; }

.btn-icon {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-secondary);
}

.btn-icon:hover { background: #f9fafb; }

.history-list { list-style: none; }

.history-empty {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  padding: 20px 0;
}

.history-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-item:last-child { border-bottom: none; }

.history-info { min-width: 0; flex: 1; }
.history-info .name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-info .meta { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.success { background: var(--success); }
.status-dot.failed { background: var(--error); }
.status-dot.building { background: var(--primary); animation: pulse 1.2s infinite; }

.history-download {
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
  flex-shrink: 0;
}

.history-copy {
  font-size: 12px;
  color: var(--primary);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.history-copy:hover { text-decoration: underline; }

.history-download:hover { text-decoration: underline; }

.history-links {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.history-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.history-del {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.history-del:hover {
  background: #fef2f2;
  color: var(--error);
  border-color: #fecaca;
}

.history-progress {
  margin-top: 6px;
}

.history-progress-track {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
}

.history-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width .4s ease;
}

.history-progress-label {
  display: block;
  font-size: 10px;
  color: var(--primary);
  margin-top: 3px;
}

.build-progress {
  margin: 14px 0 4px;
  text-align: left;
}

.build-progress-track {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}

.build-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  border-radius: 3px;
  transition: width .4s ease;
}

.build-progress-text {
  font-size: 12px;
  color: var(--primary);
  margin-top: 6px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

.hidden { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
  max-height: min(90vh, 720px);
  overflow-y: auto;
  padding: 20px;
}

.modal-card-wide {
  max-width: 640px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-header h3 { font-size: 16px; }

.modal-tip {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.modal-tip code {
  font-size: 11px;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
}

.add-user-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-field span {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.add-user-form input,
.modal-field input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  box-sizing: border-box;
}

.add-user-form .btn {
  width: 100%;
  margin-top: 4px;
}

.modal-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.stats-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.stats-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.stats-filter input[type="date"] {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  flex: 1;
  min-width: 120px;
}

.stats-filter-sep {
  font-size: 12px;
  color: var(--text-secondary);
}

.stats-summary {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.stats-table {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.stats-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.5fr 0.5fr 0.5fr;
  gap: 8px;
  padding: 8px 10px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.stats-row:last-child { border-bottom: none; }

.stats-row-head {
  background: #f9fafb;
  font-weight: 600;
  color: var(--text-secondary);
}

.stats-row b { color: var(--primary); }

.stats-log-title {
  margin-top: 16px;
}

.stats-logs {
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 280px;
  overflow: auto;
}

.stats-log-row {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 0.9fr 1.1fr 0.5fr 0.5fr;
  gap: 8px;
  padding: 8px 10px;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  min-width: 520px;
}

.stats-log-row:last-child { border-bottom: none; }

.stats-log-row-head {
  background: #f9fafb;
  font-weight: 600;
  color: var(--text-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}

.stats-log-empty {
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
}

.stats-status-success { color: var(--success); }
.stats-status-failed { color: var(--error); }
.stats-status-building { color: var(--primary); }

.history-scope-hint {
  font-size: 11px;
  color: var(--text-secondary);
  margin: -6px 0 10px;
}

.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.user-item-main {
  min-width: 0;
  flex: 1;
}

.user-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.user-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.users-list { list-style: none; }

.user-item:last-child { border-bottom: none; }

.user-del {
  color: var(--error);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
}

@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
  .main > .form-card:not(.adjust-form-card),
  .main > .adjust-form-card,
  .main > .side-panel {
    grid-column: 1;
    grid-row: auto;
  }
  .form-grid { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  .timezone-field { flex-direction: column; }
  .timezone-quick { width: 100%; }
}
