/* APITools 样式：前台 + 后台共用，风格对齐原项目（Create Video System） */
:root {
    --body-background-fill: #f9fafb;
    --background-fill-primary: white;
    --border-color-accent: #e5e7eb;
    --shadow-drop: 0 1px 3px 0 rgba(0,0,0,0.03);
    --radius-lg: 12px;
    --radius-md: 8px;
    --color-text-primary: #1f2937;
    --color-text-secondary: #6b7280;
    --color-text-label: #374151;
    --color-accent: #0d6efd;
    --color-accent-soft: #e7f1ff;
    --color-success: #198754;
    --color-danger: #dc3545;
    --color-warning: #d97706;
    --color-border: #e5e7eb;
    --color-bg-secondary: #f8f9fa;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: "Microsoft JhengHei", "微软雅黑", "PingFang SC", "Noto Sans SC", -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--body-background-fill);
    color: var(--color-text-primary);
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
/* 未登录前台：隐藏内容与导航，仅保留登录入口 */
body.logged-out .container,
body.logged-out .announcement { display: none !important; }
body.logged-out #nav-links { display: none !important; }
.site-footer {
  margin-top: auto;
  flex-shrink: 0;
  text-align: center;
  font-size: 0.72rem;
  color: #94a3b8;
  padding: 1rem 1.2rem 1.2rem;
  letter-spacing: 0.02em;
}
.admin-main > .site-footer {
  padding: 1.6rem 0 0.2rem;
}
.muted { color: var(--color-text-secondary); font-size: 0.8rem; }
.mt { margin-top: 0.9rem; }
.mb { margin-bottom: 0.9rem; }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.log-opt {
  display: inline-flex; align-items: center; gap: 0.35rem;
  margin: 0; white-space: nowrap; font-size: 0.82rem; color: var(--color-text-secondary);
  cursor: pointer; user-select: none;
}
.log-opt input { margin: 0; }

/* ---------- 顶部导航 ---------- */
.topnav {
    background: var(--background-fill-primary);
    border-bottom: 1px solid var(--border-color-accent);
    position: sticky; top: 0; z-index: 100;
}
.topnav-inner {
    max-width: 1920px; width: 100%; margin: 0 auto; padding: 0 1.25rem; height: 60px;
    display: flex; align-items: center; gap: 1rem;
}
.topnav .brand {
    display: inline-flex; align-items: center; gap: 0.5rem;
    font-size: 1.15rem; font-weight: 700; color: var(--color-text-primary);
}
.topnav .brand:hover { text-decoration: none; }
.brand-logo { height: 28px; width: auto; max-width: 120px; object-fit: contain; display: block; }
.brand-text { white-space: nowrap; }
.brand-logo-preview {
    height: 48px; max-width: 160px; width: auto; object-fit: contain;
    background: #f3f4f6; border-radius: 8px; padding: 4px; display: block;
}
.logo-setting .slot-card { cursor: default; }
.logo-setting .slot-card:hover { transform: none; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.logo-setting .slot-card img { object-fit: contain; background: #f3f4f6; }
.logo-setting .slot-list { margin-top: 0.45rem; }
.auth-brand {
    display: inline-flex; align-items: center; gap: 0.5rem;
    font-weight: 700; font-size: 1.1rem; color: var(--color-text-primary);
    margin: 0 0 0.75rem; text-decoration: none;
}
.auth-brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 0.25rem; }
.nav-link {
    padding: 0.45rem 0.95rem; border-radius: 8px; color: var(--color-text-secondary);
    font-weight: 500; font-size: 0.9rem;
}
.nav-link:hover { background: #f3f4f6; color: var(--color-text-primary); text-decoration: none; }
.nav-link.active { color: var(--color-accent); background: var(--color-accent-soft); }
.user-area { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; font-size: 0.875rem; }
.user-area .balance { color: var(--color-success); font-weight: 600; }
.user-area .uname { color: var(--color-text-primary); font-weight: 600; }
.announcement {
    max-width: 1920px; width: calc(100% - 2rem); margin: 0.9rem auto 0; color: var(--color-warning);
    font-size: 0.85rem; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px;
    display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.9rem;
}
.ann-close {
    margin-left: auto; background: none; border: none; color: inherit; font-size: 1.05rem;
    line-height: 1; cursor: pointer; padding: 0 0.2rem; height: auto; min-height: 0;
}

/* ---------- 双面板布局（原项目风格） ---------- */
.container {
    max-width: 1920px; width: 100%; margin: 1.25rem auto 2rem; padding: 0 1.25rem;
    display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: stretch;
    min-width: 0;
}
.view { width: 100%; min-width: 0; }
#view-home.container {
    display: grid;
    grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
    align-items: stretch;
}
#view-home .form-panel,
#view-home .tasks-panel {
    min-width: 0;
    max-width: none;
}
#view-home .tasks-panel { overflow: hidden; }
@media (max-width: 960px) {
    #view-home.container { grid-template-columns: 1fr; }
}
.panel {
    background-color: var(--background-fill-primary);
    border-radius: var(--radius-lg);
    border: 1px solid #e9ecef;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 1.5rem 2rem 2rem;
    transition: box-shadow 0.3s ease;
}
.panel:hover { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12); }
.panel h2 { font-size: 1.25rem; font-weight: 600; margin: 0 0 1.25rem; padding-bottom: 0.75rem; border-bottom: 1px solid #e9ecef; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }

/* ---------- 表单（对齐原项目 Gradio 风格） ---------- */
.form-group { margin-bottom: 1.1rem; }
label {
    display: block;
    color: var(--color-text-label);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.label-soft {
    text-transform: none !important;
    letter-spacing: normal !important;
    font-size: 0.8125rem !important;
    font-weight: 500 !important;
    margin-bottom: 0.35rem !important;
}
.prompt-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}
.prompt-label-row .label-soft { margin-bottom: 0 !important; }
.clear-after-submit {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-primary);
    white-space: nowrap;
}
.req-star {
  color: #dc2626;
  margin-left: 0.15rem;
  font-weight: 700;
}
.req-legend .req-star { margin: 0 0.12rem; }
input:not([type]), input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="url"],
select, textarea {
    display: block;
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background-color: var(--body-background-fill);
    font-family: inherit;
    font-size: 1rem;
    color: var(--color-text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
}
/* 生成模式切换：分段按钮（非普通单选框） */
.radio-group { display: flex; gap: 1rem; }
.radio-group input[type="radio"] { display: none; }
.radio-group label {
    flex: 1;
    text-align: center;
    padding: 0.6rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
    font-size: 0.9rem;
    margin-bottom: 0;
}
.radio-group input[type="radio"]:checked + label {
    background-color: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.2);
}
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.65rem 0.7rem; align-items: start; margin-bottom: 1.1rem; }
.settings-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.settings-grid .form-group { margin-bottom: 0; min-width: 0; }
.settings-grid .field-full { grid-column: 1 / -1; }
#model-size-row.settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  align-items: start;
  column-gap: 0.7rem;
  row-gap: 0.65rem;
}
#model-size-row .form-group {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.2rem;
}
#model-size-row .label-soft,
#model-size-row .model-label-row {
  min-height: 0;
  line-height: 1.2;
  margin-bottom: 0 !important;
  white-space: nowrap;
  overflow: hidden;
}
#model-size-row select {
  min-width: 0;
  max-width: 100%;
}
@media (max-width: 720px) {
  .settings-grid, .settings-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #model-size-row.settings-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }
}
@media (max-width: 560px) {
  .settings-grid, .settings-grid--2, #model-size-row.settings-grid { grid-template-columns: 1fr; }
}
.model-extra-hint { font-size: 12px; color: var(--color-text-secondary); margin: 0.6rem 0 0; line-height: 1.55; }

/* ---------- 按钮：全站两档高度（主按钮 / 紧凑按钮） ---------- */
button {
    box-sizing: border-box;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: var(--color-text-primary);
    height: 36px;
    min-height: 36px;
    padding: 0 1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    white-space: nowrap;
    gap: 0.25rem;
}
button:hover { border-color: #9ca3af; background: #f9fafb; }
button.primary { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
button.primary:hover { background: #0b5ed7; }
button.success { background: var(--color-success); border-color: var(--color-success); color: #fff; }
button.danger { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.small,
button.mini-btn,
.pager button,
table button,
.model-toolbar button,
.user-area button,
.panel-head button {
    height: 30px;
    min-height: 30px;
    padding: 0 0.72rem;
    font-size: 0.8rem;
    border-radius: 6px;
}
.row > button {
    height: 36px;
    min-height: 36px;
    padding: 0 1rem;
    font-size: 0.875rem;
    border-radius: 8px;
}
.row > input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
.row > select {
    height: 36px;
    min-height: 36px;
    padding: 0 0.75rem;
    font-size: 0.875rem;
}
.model-toolbar.row > button,
.model-toolbar button {
    height: 30px;
    min-height: 30px;
    padding: 0 0.72rem;
    font-size: 0.8rem;
    border-radius: 6px;
}
button.mini-btn.success,
button.small.success { background: var(--color-success); border-color: var(--color-success); color: #fff; }
button.mini-btn.success:hover,
button.small.success:hover { background: #15803d; }
button.mini-btn.danger,
button.small.danger { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }
button.mini-btn.danger:hover,
button.small.danger:hover { background: #b91c1c; }
button.mini-btn.primary,
button.small.primary { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
button.mini-btn.primary:hover,
button.small.primary:hover { background: #0b5ed7; }
.submit-btn {
    width: 100%;
    height: 36px;
    min-height: 36px;
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 0.4rem;
    padding: 0 1rem;
}
.modal-actions button {
    height: 36px;
    min-height: 36px;
    padding: 0 1rem;
    font-size: 0.875rem;
    border-radius: 8px;
}

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left; font-size: 0.78rem; font-weight: 600; color: var(--color-text-secondary);
    border-bottom: 1px solid var(--border-color-accent); padding: 0.6rem 0.5rem; white-space: nowrap;
}
tbody td { padding: 0.55rem 0.5rem; border-bottom: 1px solid #f1f3f5; font-size: 0.85rem; vertical-align: middle; }
tbody tr:hover { background: #fafbfc; }
.pager { display: flex; justify-content: center; align-items: center; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid #e9ecef; background: #f8f9fa; margin-top: 0; }
.pager .page-info { font-size: 0.875rem; color: var(--color-text-secondary); min-width: 120px; text-align: center; }
.task-prompt { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.task-prompt:hover { color: var(--color-accent); }
#task-table { table-layout: fixed; width: 100%; }
#task-table .col-id { width: 7.2rem; }
#task-table .col-model { width: 10.5rem; }
#task-table .col-prompt { width: auto; }
#task-table .col-status { width: 5.4rem; }
#task-table .col-progress { width: 8.8rem; }
#task-table .col-cost { width: 4.8rem; }
#task-table .col-time { width: 6.6rem; }
#task-table .col-elapsed { width: 4.8rem; }
#task-table .col-result { width: 8.4rem; }
#task-table th, #task-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#task-table td[data-elapsed] { font-variant-numeric: tabular-nums; }
.task-prog { display: flex; align-items: center; gap: 0.35rem; min-width: 0; }
.task-prog-num {
  display: inline-block; width: 4ch; flex-shrink: 0;
  font-variant-numeric: tabular-nums; text-align: right;
}
.result-img { max-width: 90px; max-height: 60px; border-radius: 6px; border: 1px solid var(--border-color-accent); }

/* ---------- 徽章 ---------- */
.badge { display: inline-block; padding: 0.14rem 0.55rem; border-radius: 999px; font-size: 0.74rem; font-weight: 500; }
.badge.pending { background: #fff7ed; color: #c2410c; }
.badge.processing { background: #eff6ff; color: #1d4ed8; }
.badge.completed { background: #ecfdf5; color: #047857; }
.badge.failed { background: #fef2f2; color: #b91c1c; }
.badge.cancelled { background: #f3f4f6; color: #4b5563; }
.badge.green { background: #ecfdf5; color: #047857; }
.badge.red { background: #fef2f2; color: #b91c1c; }
.badge.gray { background: #f3f4f6; color: #4b5563; }
.badge.blue { background: #eff6ff; color: #1d4ed8; }
.badge.purple { background: #f5f3ff; color: #6d28d9; }
.badge.teal { background: #f0fdfa; color: #0f766e; }

/* ---------- 上传区 ---------- */
.thumbnail-container {
    border: 2px dashed #d1d5db; border-radius: 10px; padding: 1rem; text-align: center;
    cursor: pointer; background: #fafbfc; margin-bottom: 0.6rem;
}
.thumbnail-container:hover { border-color: var(--color-accent); background: #f5f9ff; }
.upload-prompt { color: var(--color-text-secondary); font-size: 0.85rem; }
.thumb-list { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
.thumb { position: relative; width: 64px; height: 64px; }
.thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border-color-accent); }
.thumb .thumb-del {
    position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; min-height: 0; border-radius: 50%;
    background: var(--color-danger); color: #fff; border: none; font-size: 12px; line-height: 1;
    padding: 0; cursor: pointer;
}

/* ---------- 弹窗 ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(17, 24, 39, 0.5); z-index: 200;
    display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-content {
    background: #fff; border-radius: var(--radius-lg); max-width: 440px; width: 100%;
    padding: 1.6rem; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2); max-height: 92vh; overflow-y: auto;
}
.modal-content.wide { max-width: 720px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.modal-close { border: none; background: none; font-size: 1.4rem; line-height: 1; color: var(--color-text-secondary); padding: 0 0.3rem; height: auto; min-height: 0; display: inline-flex; }
.modal-close:hover { color: var(--color-text-primary); background: none; }
.auth-page {
  min-height: 100%;
  background: var(--body-background-fill);
}
.auth-page-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-page-panel {
  width: 100%;
  max-width: 420px;
}

/* ---------- Toast ---------- */
#toast-container { position: fixed; top: 70px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
    background: #111827; color: #fff; padding: 0.6rem 1rem; border-radius: 8px; font-size: 0.85rem;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2); animation: toast-in 0.2s ease;
}
.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- 后台左侧栏布局（固定侧栏，仅右侧内容滚动） ---------- */
.admin-layout { display: flex; height: 100vh; overflow: hidden; flex: 1; min-height: 0; }
.tab-page { display: none; }
.tab-page.active { display: block; }
.admin-main {
    flex: 1;
    min-width: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.4rem 1.6rem 2.4rem;
    background: var(--body-background-fill);
    display: flex;
    flex-direction: column;
}
.sidebar {
    width: 230px; background: #111827; color: #9ca3af; flex-shrink: 0;
    display: flex; flex-direction: column; height: 100vh;
}
.sidebar-brand {
    padding: 1.15rem 1.3rem; font-weight: 700; font-size: 1.05rem; color: #fff;
    border-bottom: 1px solid #1f2937;
    display: flex; align-items: center; gap: 0.5rem;
}
.sidebar-brand .brand-logo { height: 28px; max-width: 96px; }
.sidebar-nav { flex: 1; padding: 0.8rem 0.6rem; display: flex; flex-direction: column; gap: 0.15rem; overflow-y: auto; }
.sidebar-nav .tab {
    text-align: left; background: transparent; border: none; color: #9ca3af; padding: 0.6rem 0.9rem;
    border-radius: 8px; cursor: pointer; font-size: 0.9rem; font-weight: 500; display: flex; align-items: center; gap: 0.5rem;
    height: auto; min-height: 0; white-space: normal;
}
.sidebar-nav .tab:hover { background: #1f2937; color: #fff; }
.sidebar-nav .tab.active { background: var(--color-accent); color: #fff; }
.sidebar-foot { padding: 1rem 1.3rem; border-top: 1px solid #1f2937; font-size: 0.8rem; display: flex; flex-direction: column; gap: 0.5rem; }
.sidebar-foot a { color: #93c5fd; }
.model-toolbar {
  background: #f8fafc; border: 1px solid var(--border-color-accent); border-radius: 10px;
  padding: 0.45rem 0.65rem; flex-wrap: wrap; gap: 0.4rem; align-items: center;
  position: sticky; top: 0; z-index: 8;
}
.model-toolbar input {
  display: inline-block; width: auto; max-width: 200px; padding: 0.28rem 0.5rem;
  font-size: 0.8rem; height: 32px; margin: 0;
}
.price-edit { display: inline-flex; align-items: center; gap: 0.22rem; flex-wrap: nowrap; }
.price-edit input.m-price,
.price-edit input.m-tier,
.price-tier-row input.m-price,
.price-tier-row input.m-tier {
  display: inline-block; width: 4.1rem; max-width: 4.1rem; margin: 0;
  padding: 0.15rem 0.3rem; font-size: 0.78rem; height: 26px; line-height: 1.2;
  border-radius: 5px;
}
.price-tiers {
  display: flex; flex-direction: column; gap: 0.16rem; align-items: stretch; min-width: 0;
}
.price-tier-row {
  display: grid;
  grid-template-columns: 7.4rem 4.2rem auto minmax(9rem, 1fr);
  align-items: center;
  gap: 0.28rem 0.4rem;
}
.price-tiers .tier-name {
  width: auto; min-width: 0; flex-shrink: 0; font-size: 0.75rem; color: #334155;
  font-weight: 600; text-align: left; white-space: nowrap;
}
.price-tiers .muted { font-size: 0.72rem; white-space: nowrap; }
.price-tier-row .orig-hint {
  font-size: 0.7rem; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#page-models tbody td { padding: 0.35rem 0.4rem; vertical-align: top; }
.model-save-dock {
  position: sticky; bottom: 0; z-index: 8;
  display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem;
  margin: 0.4rem -0.2rem 0; padding: 0.55rem 0.8rem;
  background: #fff; border-top: 1px solid var(--border-color-accent);
  box-shadow: 0 -6px 16px rgba(15, 23, 42, 0.06);
}
.model-save-dock.has-dirty { background: #fff7ed; }
.model-save-dock button {
  height: 30px;
  min-height: 30px;
  padding: 0 0.72rem;
  font-size: 0.8rem;
  border-radius: 6px;
}
#model-table-body tr.row-dirty { background: #fff7ed; }
#model-table-body tr.row-dirty .m-price,
#model-table-body tr.row-dirty .m-tier { border-color: #fb923c; }

/* ---------- 看板统计卡片 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.stat {
    background: #fff; border: 1px solid #e9ecef; border-radius: var(--radius-lg);
    padding: 1.1rem 1.2rem; box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.stat .num { font-size: 1.5rem; font-weight: 700; color: var(--color-text-primary); }
.stat .label { font-size: 0.8rem; color: var(--color-text-secondary); margin-top: 0.2rem; }

/* ---------- 开关 ---------- */
.toggle-switch { position: relative; display: inline-block; width: 38px; height: 21px; vertical-align: middle; margin: 0; text-transform: none; letter-spacing: normal; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0; background: #d1d5db; border-radius: 999px; cursor: pointer; transition: 0.2s;
}
.toggle-slider::before {
    content: ""; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px; background: #fff;
    border-radius: 50%; transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--color-success); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(17px); }

/* ---------- 充值说明 ---------- */
.recharge-notice {
    background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px;
    padding: 0.9rem 1rem; color: #92400e; font-size: 0.9rem; line-height: 1.6;
}
/* ---------- 返回链接 ---------- */
.back-link { color: var(--color-accent); font-size: 0.85rem; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; color: var(--color-text-secondary); padding: 2.5rem 1rem; font-size: 0.9rem; }


/* ---------- 素材上传 ---------- */
.slot { margin-bottom: 0.9rem; }
.slot-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; }
.slot-head .slot-title { font-size: 0.8125rem; font-weight: 600; color: var(--color-text-label); }
.slot-dropzone {
    border: 2px dashed #d1d5db;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    background: #fafbfc;
    cursor: pointer;
    min-height: 82px;
    transition: border-color 0.2s, background 0.2s;
}
.slot-dropzone:hover, .slot-dropzone.dragover {
    border-color: var(--color-accent);
    background: #f5f9ff;
}
.negative-slot textarea {
    min-height: 82px;
    margin: 0;
    resize: vertical;
}
.slot-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 0.25rem; color: var(--color-text-secondary); font-size: 0.85rem; text-align: center;
}
.slot-empty small { color: #9ca3af; font-size: 0.78rem; }
.slot-list { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.6rem; }
.slot-card {
    position: relative; width: 84px; height: 84px; border-radius: 8px; cursor: grab;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); transition: transform 0.2s, box-shadow 0.2s;
}
.slot-card:hover { transform: translateY(-2px); box-shadow: 0 8px 16px rgba(0,0,0,0.15); z-index: 1; }
.slot-card img, .slot-card video {
    width: 84px; height: 84px; object-fit: cover; border-radius: 8px;
    border: 1px solid var(--border-color-accent); display: block; background: #fff;
}
.slot-card .slot-del {
    position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; min-height: 0; border-radius: 50%;
    background: var(--color-danger); color: #fff; border: 2px solid #fff; font-size: 12px;
    line-height: 1; padding: 0; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.slot-card.audio-card {
    width: 220px; height: 46px; display: flex; align-items: center; gap: 0.55rem;
    padding: 0 2.2rem 0 0.6rem; background: #fff; border: 1px solid var(--border-color-accent);
    cursor: grab; font-size: 0.8rem;
}
.slot-card.audio-card .slot-file-icon { font-size: 1.2rem; }
.slot-card.audio-card .slot-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-card.dragging { opacity: 0.45; cursor: grabbing !important; }
.slot-card.drag-over { outline: 2px dashed var(--color-accent); background: var(--color-accent-soft); }
.slot-card.is-uploading { cursor: default; }
.slot-card.is-uploading:hover { transform: none; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.slot-card > .slot-file-icon {
    display: flex; width: 100%; height: 100%; align-items: center; justify-content: center;
    font-size: 1.6rem; background: #fff; border: 1px solid var(--border-color-accent); border-radius: 8px;
}
.slot-card.audio-card > .slot-file-icon {
    display: inline; width: auto; height: auto; font-size: 1.2rem; background: none; border: 0; border-radius: 0;
}
.slot-upload-mask {
    position: absolute; inset: 0; border-radius: 8px;
    background: rgba(15, 23, 42, 0.58); color: #fff;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 0.32rem; font-size: 0.72rem; text-align: center; padding: 0.3rem; pointer-events: none;
}
.slot-card.audio-card .slot-upload-mask { border-radius: 8px; font-size: 0.7rem; }
.slot-upload-bar {
    width: 72%; height: 4px; background: rgba(255,255,255,0.28); border-radius: 99px; overflow: hidden;
}
.slot-upload-bar i { display: block; height: 100%; width: 0; background: #fff; border-radius: 99px; }


/* ---------- 时长拖动滑块（对齐原项目） ---------- */
#duration-row { margin-bottom: 1rem; }
#duration-row .form-group { margin-bottom: 0; }
.duration-block {
    padding: 0.7rem 0.9rem;
    background: #f8fafc;
    border: 1px solid var(--border-color-accent);
    border-radius: 10px;
}
.duration-slider-group { margin-top: 0.5rem; }
.duration-row { display: flex; align-items: center; gap: 0.75rem; }
.duration-row input[type="range"] { flex: 1; accent-color: var(--color-accent); cursor: pointer; }
.duration-row input[type="range"]:focus,
.duration-row input[type="range"]:focus-visible {
    outline: none !important;
    border-color: #d1d5db !important;
    box-shadow: none !important;
}
.duration-value { min-width: 3rem; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--color-text-primary); }
.duration-unit { color: var(--color-text-secondary); }

/* ---------- 模型格 + 「模型」标签右侧价签 ---------- */
.model-cell { grid-column: auto; min-width: 0; }
.model-label-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 0;
  margin-bottom: 0;
}
.model-label-row .label-soft {
  margin-bottom: 0 !important;
  min-height: 0 !important;
  line-height: 1.375rem;
  flex: 0 0 auto;
}
.model-label-row .price-tags {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  align-items: center;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}
.price-tags {
  display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center;
  min-height: 0;
}
.price-tag, .model-cell .price-tag {
  display: inline-flex; align-items: center; margin-left: 0; padding: 0 0.5rem;
  height: calc(0.8125rem * 1.25); box-sizing: border-box;
  border-radius: 999px; background: var(--color-accent-soft);
  color: var(--color-accent); font-size: 0.7rem; font-weight: 600; vertical-align: middle;
  text-transform: none; letter-spacing: normal; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.price-tag.unpriced {
  background: #fff7ed; color: #c2410c;
}
.price-tag.estimate {
  background: #ecfdf5; color: #047857; justify-content: center;
}
.price-tag:empty { display: none; }
td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.75rem; word-break: break-all; max-width: 160px; }
#model-size-row .model-cell select { width: 100%; font-size: 1rem; padding: 0.75rem; height: auto; min-height: 49px; }

/* ---------- 复建任务弹窗 ---------- */
.modal-actions { display: flex; gap: 0.6rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.confirm-body { margin: 0; line-height: 1.65; color: var(--color-text-primary); }
.rebuild-prompt {
  background: #f8fafc; border: 1px solid var(--border-color-accent);
  border-radius: 10px; padding: 0.8rem 1rem; white-space: pre-wrap; word-break: break-all;
  font-size: 0.9rem; margin: 0 0 0.9rem; max-height: 240px; overflow: auto;
}
.rebuild-params { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.rebuild-params td { padding: 0.4rem 0.6rem; border-bottom: 1px solid #f1f5f9; }
.rebuild-params td:first-child { color: var(--color-text-secondary); width: 140px; white-space: nowrap; }

/* ---------- 后台详情弹窗 ---------- */
#admin-modal .modal-content { max-height: 80vh; overflow: auto; }
#admin-modal .table-wrap { max-height: 60vh; overflow: auto; }


/* ---------- 列表进度条 / 保留标签 / 结果与失败弹窗 ---------- */
.task-progress { width: 70px; height: 6px; border-radius: 999px; background: #e5e7eb; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 0.35rem; }
.task-progress-bar { height: 100%; background: var(--color-accent); border-radius: 999px; transition: width 0.6s ease; }

.retention-tag {
  display: inline-block; padding: 0.16rem 0.6rem; border-radius: 999px;
  background: #eff6ff; color: #1d4ed8; font-size: 0.75rem; font-weight: 500;
  border: 1px solid #bfdbfe; white-space: nowrap;
}

.result-modal-content { max-width: 760px; }
.result-body { text-align: center; }
.result-body .result-modal-img {
  max-width: 100%; max-height: 62vh; border-radius: 10px;
  border: 1px solid var(--border-color-accent); object-fit: contain;
}
.result-body .result-modal-video {
  width: 100%; max-height: 62vh; border-radius: 10px; background: #000;
}
.result-img { cursor: pointer; }
.result-img:hover { border-color: var(--color-accent); opacity: 0.92; }

.error-body {
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  border-radius: 10px; padding: 0.8rem 1rem; font-size: 0.85rem;
  white-space: pre-wrap; word-break: break-all; max-height: 40vh; overflow: auto;
}
.error-hint { margin-top: 0.7rem; }

/* ---------- 任务列表右键菜单 ---------- */
.context-menu {
  position: fixed; display: none; z-index: 400;
  min-width: 160px; background: #fff; border: 1px solid var(--color-border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.14); padding: 0.25rem 0;
}
.context-menu.visible { display: block; }
.context-menu-item {
  padding: 0.5rem 0.95rem; cursor: pointer; font-size: 0.85rem; color: var(--color-text-primary);
}
.context-menu-item:hover { background: #f3f4f6; }
.context-menu-item:active { background: var(--color-accent); color: #fff; }

/* ---------- 后台日志/响应详情 ---------- */
.log-pre {
  background: #f8fafc; border: 1px solid var(--border-color-accent); border-radius: 8px;
  padding: 0.6rem 0.7rem; font-size: 0.78rem; font-family: Consolas, Menlo, monospace;
  white-space: pre-wrap; word-break: break-all; max-height: 240px; overflow: auto; margin: 0 0 0.8rem;
}

@media (max-width: 900px) {
  .admin-layout { flex-direction: column; height: auto; overflow: visible; }
  .sidebar { width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; overflow: visible; }
  .sidebar-foot { border-top: none; }
  .admin-main { height: auto; overflow: visible; padding: 1rem; }
}
