/* ============================================================================
   AI抠图工具 Web 后台 — 管理界面样式（无构建静态 SPA）
   设计：浅色内容区 + 深色侧栏，圆角 12–14px，柔和阴影，品牌蓝 #2563EB
   ========================================================================== */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e8ecf3;
  --border-strong: #d8dfea;
  --text: #1f2937;
  --text-soft: #5b6577;
  --text-mute: #94a0b3;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eaf1ff;
  --success: #0f9d58;
  --success-soft: #e7f6ee;
  --warn: #d97706;
  --warn-soft: #fef3e2;
  --danger: #dc2626;
  --danger-soft: #fdeced;
  --sidebar-1: #1c2233;
  --sidebar-2: #262f4a;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; }

/* ---------- 登录 / 改密 视图 ---------- */
.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 600px at 12% -5%, #2c3c6b 0%, rgba(44, 60, 107, 0) 55%),
    radial-gradient(900px 520px at 100% 0%, #1f6feb33 0%, rgba(31, 111, 235, 0) 50%),
    linear-gradient(160deg, #10141f 0%, #1b2233 55%, #242e49 100%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 18px;
  padding: 34px 32px 28px;
  box-shadow: var(--shadow-lg);
}

.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-logo {
  width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, #3b82f6, #2563eb);
  color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}
.auth-brand h1 { font-size: 18px; }
.auth-brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-mute); }

/* ---------- 应用外壳 ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex: 0 0 236px;
  background: linear-gradient(180deg, var(--sidebar-1), var(--sidebar-2));
  color: #cbd4e6;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 6px 8px 18px;
  color: #fff;
}
.sidebar-brand .logo {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, #3b82f6, #2563eb);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}
.sidebar-brand .t { font-size: 14.5px; font-weight: 650; letter-spacing: 0.2px; }
.sidebar-brand .s { font-size: 11.5px; color: #8b97b5; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: #b6c0d6; cursor: pointer; user-select: none;
  font-size: 13.5px; transition: background 0.16s, color 0.16s;
  border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.active {
  background: linear-gradient(120deg, rgba(59, 130, 246, 0.95), rgba(37, 99, 235, 0.85));
  color: #fff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}
.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; }

.sidebar-foot { margin-top: auto; padding: 10px 8px 2px; font-size: 11.5px; color: #6f7c98; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 62px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-size: 16px; font-weight: 650; }
.topbar .subtitle { font-size: 12.5px; color: var(--text-mute); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-soft);
}
.avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(140deg, #60a5fa, #2563eb);
  color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700;
}

.content { padding: 24px 26px 60px; max-width: 1180px; width: 100%; }
.page { display: none; }
.page.active { display: block; animation: fade 0.22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.card-head h3 { font-size: 15px; }
.card-head .desc { font-size: 12.5px; color: var(--text-mute); margin-top: 3px; }

.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .label { font-size: 12.5px; color: var(--text-mute); display: flex; align-items: center; gap: 7px; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 8px; letter-spacing: 0.2px; }
.stat .value.small { font-size: 15px; word-break: break-all; }
.stat .foot { font-size: 12px; color: var(--text-soft); margin-top: 4px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.8px; color: var(--text-soft); margin-bottom: 6px; font-weight: 550; }
.field .hint { font-size: 11.8px; color: var(--text-mute); margin-top: 5px; }

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--text); font-size: 13.5px;
  font-family: inherit; transition: border 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}
input[readonly] { background: var(--surface-2); color: var(--text-soft); }
.inline { display: flex; gap: 10px; align-items: center; }
.inline > * { flex: 1; }
.inline > .no-flex { flex: 0 0 auto; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--surface-2); color: var(--text);
  font-size: 13.3px; font-weight: 550; cursor: pointer; font-family: inherit;
  transition: background 0.15s, box-shadow 0.15s, transform 0.05s, border 0.15s;
  white-space: nowrap;
}
.btn:hover { background: #eef1f6; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fbd9db; }
.btn-ghost { background: transparent; border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 11px; font-size: 12.4px; border-radius: 9px; }
.btn-block { width: 100%; padding: 11px; }

/* ---------- 徽章 / 开关 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.8px; font-weight: 600;
}
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--danger-soft); color: var(--danger); }
.badge.mute { background: #eef1f6; color: var(--text-soft); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot.err { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.dot.mute { background: var(--text-mute); }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: 0 0 40px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer; border-radius: 999px;
  background: #cfd6e2; transition: 0.2s;
}
.switch .slider::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:disabled + .slider { opacity: 0.5; cursor: not-allowed; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-mute);
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--surface-2); position: sticky; top: 0;
}
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.mono { font-family: var(--mono); font-size: 12.2px; }
.muted { color: var(--text-mute); }
.nowrap { white-space: nowrap; }
.row-actions { display: flex; gap: 7px; flex-wrap: wrap; }

/* ---------- 提示条 ---------- */
.banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: 12.8px; margin-bottom: 16px; line-height: 1.5;
}
.banner.info { background: var(--primary-soft); color: #1e40af; }
.banner.warn { background: var(--warn-soft); color: #92400e; }
.banner.err { background: var(--danger-soft); color: #991b1b; }
.banner.ok { background: var(--success-soft); color: #065f46; }

.empty { text-align: center; color: var(--text-mute); padding: 40px 12px; font-size: 13px; }
.empty svg { opacity: 0.5; margin-bottom: 8px; }

/* ---------- 模态 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(3px); display: none; align-items: center; justify-content: center;
  padding: 20px; z-index: 60;
}
.overlay.show { display: flex; }
.modal {
  width: 100%; max-width: 520px; background: #fff; border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 22px; animation: pop 0.18s ease;
  max-height: 88vh; overflow-y: auto;
}
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(8px); } to { opacity: 1; transform: none; } }
.modal h3 { font-size: 16px; margin-bottom: 4px; }
.modal .modal-sub { font-size: 12.5px; color: var(--text-mute); margin-bottom: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Toast ---------- */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 240px; max-width: 380px; padding: 12px 15px; border-radius: 12px;
  background: #1f2937; color: #fff; font-size: 13px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 9px; animation: slidein 0.22s ease;
}
.toast.ok { background: #0f9d58; }
.toast.err { background: #dc2626; }
.toast.warn { background: #d97706; }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------- 加载 ---------- */
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff;
  animation: spin 0.7s linear infinite; display: inline-block;
}
.spinner.dark { border-color: rgba(37, 99, 235, 0.25); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, #eef1f6 25%, #e2e8f2 37%, #eef1f6 63%); background-size: 400% 100%; animation: sk 1.2s ease infinite; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- 标签页小工具栏 ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; min-width: 180px; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-mute); }
.search-wrap input { padding-left: 34px; }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 14px; font-size: 12.5px; color: var(--text-soft); }

.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 2px 7px; font-size: 11.5px; color: var(--text-soft); font-family: var(--mono); }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 9px 0; }
.tl-item::before {
  content: ""; position: absolute; left: -20px; top: 14px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.tl-item .tl-head { font-size: 13px; font-weight: 550; }
.tl-item .tl-meta { font-size: 11.8px; color: var(--text-mute); margin-top: 2px; }
.tl-item .tl-detail { font-size: 12.4px; color: var(--text-soft); margin-top: 4px; word-break: break-word; }

.section-title { font-size: 13px; font-weight: 600; color: var(--text-soft); margin: 22px 0 10px; }
.hidden { display: none !important; }

@media (max-width: 860px) {
  .sidebar { width: 68px; flex-basis: 68px; padding: 14px 8px; }
  .sidebar-brand .t, .sidebar-brand .s, .nav-item span, .sidebar-foot { display: none; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .content { padding: 16px; }
}
