* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #f5f7fb;
  color: #1f2937;
  font-size: 14px;
}
a { color: #4b5fde; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ----- Top nav ----- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: #fff;
  border-bottom: 1px solid #e7eaf3;
  padding: 14px 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.brand .logo {
  width: 38px; height: 38px;
  background: linear-gradient(135deg,#4b5fde,#7b87f5);
  border-radius: 9px;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 4px 10px rgba(75,95,222,0.25);
}
.brand .title { font-size: 16px; font-weight: 700; color: #111827; }
.brand .subtitle { font-size: 12px; color: #6b7280; margin-top: 2px; font-family: ui-monospace,Consolas,monospace; }

.tabs {
  display: flex;
  gap: 6px;
  flex: 1;
}
.tabs a {
  padding: 8px 16px;
  border-radius: 10px;
  color: #4b5563;
  font-weight: 500;
}
.tabs a.active { background: #eef1ff; color: #4b5fde; }
.tabs a:hover:not(.active) { background: #f3f4f6; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.wallet {
  background: #fff;
  border: 1px solid #e7eaf3;
  border-radius: 10px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.wallet .label { color: #6b7280; font-size: 12px; }
.wallet .amount { color: #4b5fde; font-weight: 700; font-size: 18px; }

.btn {
  border: 1px solid #e7eaf3;
  background: #fff;
  color: #1f2937;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  transition: all 0.15s;
}
.btn:hover { border-color: #c5cce5; background: #f8f9ff; }
.btn-primary {
  background: #2c40d8;
  color: #fff;
  border-color: #2c40d8;
}
.btn-primary:hover { background: #1f31bd; border-color: #1f31bd; }
.btn-danger { color: #dc2626; }
.btn-block { width: 100%; padding: 14px; font-size: 15px; font-weight: 600; }

/* ----- Layout ----- */
.workspace {
  display: grid;
  grid-template-columns: 320px 1fr 1fr;
  gap: 20px;
  padding: 20px 28px;
  align-items: start;
}
.panel {
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e7eaf3;
  padding: 20px;
}
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.panel-title h2 { margin: 0; font-size: 16px; color: #4b5fde; }
.panel-title .meta { color: #6b7280; font-size: 12px; }
.panel-title .link { color: #16a34a; font-size: 13px; cursor: pointer; }

/* ----- Left panel ----- */
.section-label { font-size: 13px; color: #374151; margin: 14px 0 8px; font-weight: 600; }
.size-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.size-card {
  border: 1px solid #e7eaf3;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  background: #f8f9ff;
  transition: all 0.15s;
}
.size-card:hover { border-color: #4b5fde; }
.size-card.active {
  background: #1d2230;
  color: #fff;
  border-color: #1d2230;
}
.size-card .size {
  font-weight: 700;
  color: #4b5fde;
  font-size: 15px;
}
.size-card.active .size { color: #fff; }
.size-card .ratio { font-size: 11px; color: #9ca3af; margin-top: 2px; }
.size-card.active .ratio { color: #cbd5e1; }
.size-card.full { grid-column: 1 / -1; padding: 14px; }

.custom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.field label { display: block; font-size: 12px; color: #6b7280; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #e7eaf3;
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  color: #1f2937;
  font-family: inherit;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #4b5fde;
}
.hint {
  background: #f3f4f6;
  border-radius: 8px;
  padding: 8px 10px;
  color: #6b7280;
  font-size: 12px;
  margin-top: 8px;
}

.quality-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.quality-row .seg {
  padding: 9px 0;
  text-align: center;
  border: 1px solid #e7eaf3;
  border-radius: 8px;
  background: #f8f9ff;
  font-size: 13px;
  cursor: pointer;
}
.quality-row .seg.active { background: #1d2230; color: #fff; border-color: #1d2230; }

.model-row { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }

/* ----- Middle panel ----- */
.prompt-box {
  display: flex;
  flex-direction: column;
  min-height: 600px;
}
.prompt-box textarea {
  flex: 1;
  min-height: 460px;
  resize: vertical;
  border: 1px solid #e7eaf3;
  border-radius: 10px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.6;
  outline: none;
  font-family: inherit;
}
.prompt-box textarea:focus { border-color: #4b5fde; }
.queue-status { color: #16a34a; font-size: 13px; margin-top: 10px; }

/* ----- Right panel ----- */
.result-meta { color: #6b7280; font-size: 12px; }
.result-meta .model { color: #4b5fde; font-weight: 600; }
.result-empty {
  border: 1px dashed #d1d5db;
  border-radius: 10px;
  padding: 60px 20px;
  text-align: center;
  color: #9ca3af;
}
.result-image {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e7eaf3;
  margin-top: 12px;
}
.result-image img { display: block; width: 100%; }
.result-actions { margin-top: 12px; }

/* ----- Auth pages ----- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #eef1ff 0%, #f9fafb 100%);
}
.auth-card {
  width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 10px 40px rgba(31,49,189,0.08);
  border: 1px solid #e7eaf3;
}
.auth-card h1 {
  margin: 0 0 6px;
  color: #4b5fde;
  font-size: 22px;
}
.auth-card .lead { color: #6b7280; font-size: 13px; margin-bottom: 22px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .switch {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: #6b7280;
}

/* ----- Settings page ----- */
.settings-wrap { padding: 28px; max-width: 1100px; margin: 0 auto; }
.settings-wrap h1 { margin-top: 0; color: #4b5fde; }
.model-card {
  background: #fff;
  border: 1px solid #e7eaf3;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 14px;
}
.model-card .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.model-card .name { font-weight: 700; font-size: 15px; }
.model-card .badge {
  font-size: 11px;
  background: #eef1ff;
  color: #4b5fde;
  padding: 3px 9px;
  border-radius: 999px;
}
.model-card .row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.model-card .meta { font-size: 12px; color: #6b7280; margin-top: 6px; }

/* ----- Misc ----- */
.flash {
  background: #fee2e2;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}
.flash.success { background: #dcfce7; color: #166534; }
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45);
  display: grid; place-items: center; z-index: 100;
}
.modal {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  width: 420px;
}
.modal h3 { margin: 0 0 14px; color: #4b5fde; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.placeholder-pane {
  padding: 60px 24px;
  text-align: center;
  color: #9ca3af;
}
.placeholder-pane h3 { color: #6b7280; }

/* ----- Progress bar ----- */
.progress-wrap { margin-top: 12px; }
.progress-bar {
  height: 8px;
  background: #eef1ff;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg,#4b5fde,#7b87f5);
  transition: width 0.2s linear;
}
.progress-text {
  font-size: 12px;
  color: #6b7280;
  margin-top: 6px;
  text-align: center;
}

/* ----- Image viewer modal ----- */
.viewer-mask { background: rgba(15,23,42,0.78); }
.viewer {
  background: #fff;
  border-radius: 14px;
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.viewer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #e7eaf3;
  gap: 12px;
}
.viewer-name {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  color: #6b7280;
  word-break: break-all;
}
.viewer-actions { display: flex; gap: 8px; flex-shrink: 0; }
.viewer-body {
  flex: 1;
  overflow: auto;
  display: grid;
  place-items: center;
  background: #0f172a;
  padding: 16px;
}
.viewer-body img { max-width: 100%; max-height: 80vh; display: block; border-radius: 6px; }

/* ----- Thumbnails / history ----- */
.thumb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.thumb {
  width: 160px;
  height: 160px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e7eaf3;
  cursor: zoom-in;
  background: #f3f4f6;
  position: relative;
  transition: transform 0.15s;
}
.thumb:hover { transform: translateY(-2px); border-color: #4b5fde; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.result-image { cursor: zoom-in; }

/* ----- Filters bar ----- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  background: #fff;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #e7eaf3;
  margin-bottom: 16px;
}
.filter-bar .field { min-width: 160px; flex: 0 0 auto; margin: 0; }

/* ----- Admin user table ----- */
.user-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e7eaf3;
  border-radius: 12px;
  overflow: hidden;
}
.user-table th, .user-table td {
  padding: 10px 14px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid #f1f3fa;
}
.user-table th { background: #f8f9ff; color: #6b7280; font-weight: 600; }
.user-table tr:last-child td { border-bottom: none; }
.user-table .badge {
  background: #eef1ff; color: #4b5fde;
  padding: 2px 8px; border-radius: 999px; font-size: 11px;
}

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 1fr; }
}
