/* 后台管理样式（浅色主题） */
:root {
  --bg: #f1f5f9; --panel: #fff; --panel-2: #f8fafc; --border: #e2e8f0;
  --text: #1e293b; --text-2: #475569; --muted: #94a3b8;
  --primary: #0f172a; --brand: #0e7490; --brand-2: #0891b2; --brand-soft: #ecfeff;
  --danger: #dc2626; --danger-soft: #fef2f2; --success: #059669;
  --shadow: 0 1px 3px rgba(15,23,42,.06); --shadow-md: 0 8px 24px rgba(15,23,42,.10);
  --radius: 9px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Consolas, Menlo, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* 登录 */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #ecfeff 0%, #f1f5f9 60%, #f0fdfa 100%); }
.login-card { width: 380px; background: #fff; border-radius: 16px; padding: 36px; box-shadow: var(--shadow-md); border: 1px solid var(--border); }
.login-card .logo { width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(135deg,var(--brand),#0d9488); color:#fff; display:flex; align-items:center; justify-content:center; font-size:22px; font-weight:700; margin-bottom:16px; }
.login-card h2 { margin: 0 0 4px; font-size: 20px; }
.login-card .sub { color: var(--muted); margin: 0 0 24px; font-size: 13px; }
.login-card input { width: 100%; height: 44px; border: 1px solid var(--border); border-radius: 8px; padding: 0 14px; font-size: 14px; outline: none; }
.login-card input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
.login-card button { width: 100%; height: 44px; margin-top: 14px; border: 0; border-radius: 8px; background: var(--brand); color: #fff; font-size: 14px; font-weight: 600; }
.login-card button:hover { background: var(--brand-2); }
.login-card .err { color: var(--danger); font-size: 12px; margin-top: 10px; min-height: 16px; }
.login-card .back { display: block; text-align: center; margin-top: 16px; font-size: 12px; color: var(--muted); }

/* 框架 */
.admin-wrap { display: none; min-height: 100vh; }
.admin-wrap.show { display: flex; }
.side { width: 220px; flex-shrink: 0; background: var(--primary); color: #cbd5e1; position: fixed; top: 0; bottom: 0; left: 0; display: flex; flex-direction: column; }
.side .logo { padding: 20px; font-size: 16px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 9px; }
.side .logo i { width: 30px; height: 30px; border-radius: 8px; background: var(--brand-2); display: flex; align-items: center; justify-content: center; font-style: normal; font-size: 16px; }
.nav { padding: 12px 10px; flex: 1; }
.nav-item { padding: 11px 14px; border-radius: 7px; cursor: pointer; display: flex; align-items: center; gap: 10px; margin-bottom: 3px; font-size: 13.5px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--brand-2); color: #fff; font-weight: 600; }
.side .foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.side .foot a { color: #94a3b8; }
.content { margin-left: 220px; flex: 1; padding: 26px 30px; min-width: 0; }
.content-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.content-head h1 { margin: 0; font-size: 21px; }
.content-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* 通用组件 */
.btn { border: 1px solid var(--border); background: #fff; color: var(--text-2); padding: 8px 15px; border-radius: 7px; font-size: 13px; font-weight: 500; }
.btn:hover { border-color: var(--brand-2); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); color: #fff; }
.btn-danger { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: var(--panel-2); color: var(--text-2); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fafcfd; }
.badge { display: inline-block; background: var(--brand-soft); color: var(--brand); padding: 2px 9px; border-radius: 11px; font-size: 11px; }
.badge-gray { background: #f1f5f9; color: var(--text-2); }
.empty-row td { text-align: center; color: var(--muted); padding: 40px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none; align-items: center; justify-content: center; z-index: 100; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 520px; max-width: 92vw; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-md); }
.modal.wide { width: 860px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.modal-head .x { cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--text-2); font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--border); border-radius: 7px; padding: 9px 12px; font-size: 13px; outline: none; font-family: inherit; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
.field textarea { resize: vertical; }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* 模板编辑器 */
.tmpl-layout { display: flex; gap: 0; min-height: 460px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.tmpl-types { width: 190px; flex-shrink: 0; background: var(--panel-2); border-right: 1px solid var(--border); padding: 8px; }
.tmpl-type { padding: 9px 11px; border-radius: 6px; cursor: pointer; font-size: 12.5px; margin-bottom: 2px; color: var(--text-2); }
.tmpl-type:hover { background: #fff; }
.tmpl-type.active { background: var(--brand); color: #fff; font-weight: 600; }
.tmpl-edit { flex: 1; padding: 14px; min-width: 0; }
.tmpl-edit .field { margin-bottom: 10px; }
.tmpl-edit textarea { font-family: var(--mono); font-size: 12px; line-height: 1.6; min-height: 320px; }
.doc-tabs-mini { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 10px; }
.doc-tab-mini { padding: 4px 10px; border: 1px solid var(--border); background: #fff; border-radius: 6px; font-size: 11px; color: var(--text-2); }
.doc-tab-mini.active { background: var(--accent, #0d9488); border-color: var(--accent, #0d9488); color: #fff; }

.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px); background: #1e293b; color: #fff; padding: 10px 22px; border-radius: 8px; font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; z-index: 200; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.settings-box { max-width: 480px; }

/* 上传进度 */
#upQueue { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.up-item { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 11px 14px; }
.up-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 7px; }
.up-name { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.up-pct { flex-shrink: 0; font-size: 12px; font-weight: 600; color: var(--brand); font-variant-numeric: tabular-nums; }
.up-track { height: 7px; background: var(--border); border-radius: 4px; overflow: hidden; }
.up-fill { height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .15s ease; }
.up-item.done .up-pct, .up-inline.done .up-pct { color: var(--success); }
.up-item.done .up-fill, .up-inline.done .up-fill { background: var(--success); }
.up-item.fail .up-pct, .up-inline.fail .up-pct { color: var(--danger); }
.up-item.fail .up-fill, .up-inline.fail .up-fill { background: var(--danger); }
.up-inline { margin-top: 9px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel-2); }

/* 手机 / 平板 */
@media (max-width: 900px) {
  .login-card { width: calc(100% - 32px); padding: 26px; }
  .admin-wrap.show { display: block; }
  .side { position: static; width: 100%; height: auto; }
  .side .logo { padding: 12px 16px; }
  .side .nav { display: flex; overflow-x: auto; padding: 8px 10px; gap: 4px; -webkit-overflow-scrolling: touch; }
  .nav-item { white-space: nowrap; margin: 0; padding: 9px 12px; font-size: 12.5px; }
  .side .foot { display: none; }
  .content { margin-left: 0; padding: 16px; }
  .content-head { display: block; }
  .content-head h1 { font-size: 18px; }
  #headActions { margin-top: 10px; }
  .panel { overflow-x: auto; }
  table { min-width: 560px; }
  .grid2 { grid-template-columns: 1fr; gap: 0; }
  .modal { width: 100%; max-width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .modal.wide { width: 100%; }
  .modal-body { padding: 16px; }
  .modal-head, .modal-foot { padding: 14px 16px; }
  .tmpl-layout { flex-direction: column; }
  .tmpl-types { width: 100%; display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .tmpl-type { white-space: nowrap; margin: 0 4px 0 0; }
  .tmpl-edit { padding: 10px; }
  .tmpl-edit textarea { min-height: 260px; }
  .settings-box { max-width: none; }
}
