/* ============ 基础 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #6366f1;
  --accent: #8b5cf6;
  --bg: #f4f5fb;
  --card: #fff;
  --text: #23283a;
  --muted: #8a90a3;
  --border: #e6e8f0;
  --danger: #e5484d;
  --success: #1aa563;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ============ 登录页 ============ */
.login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #d946ef 100%);
  padding: 20px;
}
.login-card {
  width: 380px; background: #fff; border-radius: 18px; padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); text-align: center;
}
.login-logo {
  width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-size: 26px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-tip { margin-top: 16px; font-size: 12px; color: var(--muted); }
#loginForm { text-align: left; }

/* ============ 表单 ============ */
.form-item { margin-bottom: 14px; }
.form-item label { display: block; font-size: 13px; color: #4a4f63; margin-bottom: 6px; font-weight: 500; }
.form-item input, .form-item select {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none; background: #fff; transition: border .2s;
}
.form-item input:focus, .form-item select:focus { border-color: var(--primary); }
.form-row { display: flex; gap: 12px; }
.form-row .form-item { flex: 1; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { display: none; }
.switch span {
  position: absolute; inset: 0; background: #d5d9e8; border-radius: 999px; cursor: pointer; transition: .25s;
}
.switch span::after {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .25s;
}
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ============ 按钮 ============ */
.btn-primary, .btn-outline {
  border: none; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600;
  padding: 9px 18px; transition: all .2s;
}
.btn-primary { background: linear-gradient(120deg, var(--primary), var(--accent)); color: #fff; }
.btn-primary:hover { opacity: .9; transform: translateY(-1px); }
.btn-primary.block { width: 100%; padding: 11px 0; font-size: 15px; margin-top: 6px; }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: #f0f2ff; }
.btn-danger { background: #fff; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-danger:hover { background: #fff0f0; }

/* ============ 主布局 ============ */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #1e2233; color: #cfd3e6; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; flex-shrink: 0;
}
.side-logo { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.logo-badge {
  width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 700;
}
.side-logo b { display: block; font-size: 14px; color: #fff; }
.side-logo small { font-size: 11px; color: #8a90a3; }
.side-nav { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  width: 100%; text-align: left; background: transparent; border: none; color: #cfd3e6;
  padding: 10px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; transition: all .2s;
}
.nav-item:hover { background: rgba(255,255,255,.07); }
.nav-item.active { background: linear-gradient(120deg, var(--primary), var(--accent)); color: #fff; }
.side-footer { padding: 14px 10px; border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; padding: 24px 28px; overflow-x: hidden; }
.view { display: none; }
.view.active { display: block; }
.view-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.view-header h2 { font-size: 19px; }
.muted { color: var(--muted); font-size: 12px; }

/* ============ 仪表盘 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 20px; border: 1px solid var(--border); box-shadow: 0 4px 14px rgba(80,90,200,.05); }
.stat-num { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card.accent .stat-num { color: var(--accent); }
.stat-card.green .stat-num { color: var(--success); }
.stat-card.orange .stat-num { color: #d9822b; }
.stat-card.purple .stat-num { color: #a855f7; }
.stat-card.gold {
  background: linear-gradient(135deg, #fff9e6 0%, #fff4cc 100%);
  border: 1px solid #e9c34f;
}
.stat-card.gold .stat-num { color: #b07d0f; font-weight: 800; }
.stat-label { color: var(--muted); font-size: 12px; margin-top: 4px; }

.card { background: var(--card); border-radius: var(--radius); padding: 20px; border: 1px solid var(--border); margin-bottom: 16px; box-shadow: 0 4px 14px rgba(80,90,200,.05); }
.card h3 { font-size: 15px; margin-bottom: 14px; }
.qa-row { display: flex; flex-wrap: wrap; gap: 10px; }
.guide { padding-left: 20px; line-height: 2; color: #4a4f63; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 600; background: #fafbff; }
tr:hover td { background: #fafbff; }
.loading-td { text-align: center; color: var(--muted); padding: 30px 0; }
.empty-td { text-align: center; color: var(--muted); padding: 30px 0; }
td .op { display: flex; gap: 6px; flex-wrap: wrap; }
td .op .btn-outline, td .op .btn-danger { padding: 6px 10px; font-size: 12px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.tag.on { background: #e9fff2; color: var(--success); }
.tag.off { background: #f0f1f6; color: var(--muted); }
.tag.lang-zh { background: #fff3e0; color: #d9822b; }
.tag.lang-ja { background: #ffe9ee; color: #d24b6a; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20,22,40,.5); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 14px; width: 560px; max-width: 100%;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-footer { display: flex; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); }
.modal-footer .btn-primary { margin-left: auto; }
.tip { font-size: 12px; color: var(--muted); margin-bottom: 14px; line-height: 1.7; }
.tip a { color: var(--primary); }

/* 上传框 */
.upload-box {
  border: 2px dashed #c9cdf5; border-radius: 10px; padding: 22px; text-align: center;
  cursor: pointer; position: relative; background: #fafbff; transition: all .2s;
}
.upload-box:hover { border-color: var(--primary); background: #f2f3ff; }
.upload-box input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-hint { color: #4a4f63; font-size: 14px; }
.upload-box.has-file { border-style: solid; border-color: var(--success); background: #f2fdf7; }

/* ffmpeg 状态提示卡 */
.bgm-status-card { display: flex; align-items: center; gap: 12px; background: #fff8ec; border-color: #ffd99a; }
.bgm-status-icon { font-size: 22px; line-height: 1; }
.bgm-status-card b { font-size: 14px; color: #b46a00; display: block; margin-bottom: 4px; }
.bgm-status-card p { font-size: 12px; color: var(--muted); margin: 0; }

/* 训练文本 */
.text-train { margin-top: 14px; background: #f6f7ff; border: 1px solid #dfe1ff; border-radius: 10px; padding: 14px; }
.text-train-title { font-size: 12px; color: var(--primary); font-weight: 600; margin-bottom: 8px; }
.text-train-content { font-size: 14px; line-height: 1.8; background: #fff; padding: 10px; border-radius: 8px; margin-bottom: 8px; }
.text-train-id { font-size: 12px; color: var(--muted); word-break: break-all; }

/* 声音水印状态卡 */
.wm-status { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; padding: 8px 0 4px; }
.wm-info { flex: 1; min-width: 260px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; }
.wm-row { font-size: 13px; line-height: 1.9; }
.wm-row .muted { color: var(--muted); margin-right: 4px; }
.wm-player { flex: 1; min-width: 240px; max-width: 360px; background: #f6f7ff; border: 1px solid #dfe1ff; border-radius: 10px; padding: 12px; }
.wm-actions { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 0; align-items: center; }

/* 会员管理 */
.user-filter { padding: 14px 16px; }
.filter-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-row input, .filter-row select { height: 38px; border: 1px solid #dfe1ff; border-radius: 8px; padding: 0 12px; font-size: 13px; outline: none; background: #fff; }
.filter-row input:focus, .filter-row select:focus { border-color: var(--primary); }
.user-pager { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; }
.user-pager .pg-btn { min-width: 32px; height: 32px; border: 1px solid #dfe1ff; background: #fff; border-radius: 6px; cursor: pointer; font-size: 13px; color: #4a4f63; }
.user-pager .pg-btn:hover { border-color: var(--primary); color: var(--primary); }

/* OSS 配置 */
.oss-card { border-left: 4px solid #1a73e8; }
.oss-status { margin-bottom: 10px; }
.switch-row { display: flex; align-items: center; gap: 12px; }
.switch { position: relative; display: inline-block; width: 46px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .3s; border-radius: 24px; }
.switch .slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; }
.switch input:checked + .slider { background-color: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(22px); }
.view-oss code { background: #f0f2f8; padding: 2px 6px; border-radius: 4px; font-size: 12px; font-family: monospace; }
.user-pager .pg-current { min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; background: var(--primary); color: #fff; border-radius: 6px; font-size: 13px; font-weight: 600; }

@media (max-width: 768px) {
  .wm-info { grid-template-columns: 1fr; }
  .wm-player { max-width: 100%; }
}

/* Toast */
#toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: #32343f; color: #fff; padding: 10px 22px; border-radius: 8px;
  font-size: 14px; z-index: 999; opacity: 0; pointer-events: none; transition: opacity .25s; max-width: 80%;
}
#toast.show { opacity: 1; }
#toast.error { background: #e5484d; }

@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .side-logo div, .side-logo b, .side-logo small, .side-nav .nav-item { display: none; }
  .side-nav .nav-item { display: block; text-align: center; padding: 12px 0; }
  .main { padding: 16px; }
}
