/* 辛月半后台管理系统 · 样式 */
:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eef2ff;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --success-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --sidebar: #111827;
  --sidebar-text: #cbd5e1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- 启动遮罩 ---------- */
.boot-mask {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 80;
}
.boot-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 登录 ---------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 12% -10%, #e0e7ff 0%, rgba(224, 231, 255, 0) 60%),
    radial-gradient(900px 500px at 100% 0%, #dbeafe 0%, rgba(219, 234, 254, 0) 55%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border-radius: 18px;
  padding: 32px 28px 24px;
  box-shadow: 0 20px 50px rgba(30, 41, 59, .12);
  border: 1px solid rgba(226, 232, 240, .9);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-brand h1 { font-size: 18px; margin: 0; letter-spacing: .5px; }
.login-brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  flex: 0 0 auto;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .35);
}
.logo-sm { width: 34px; height: 34px; font-size: 16px; border-radius: 10px; }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

.checkbox { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin: 4px 0 14px; }
.checkbox input { width: 15px; height: 15px; accent-color: var(--brand); }

.form-error { color: var(--danger); font-size: 13px; min-height: 20px; margin: 0 0 8px; }
.login-tip { color: var(--muted); font-size: 12px; text-align: center; margin: 16px 0 0; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-outline { border-color: var(--line); background: #fff; }
.btn-outline:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--sidebar-text); }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, .08); }
.btn-ghost.danger:hover:not(:disabled) { color: #fca5a5; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; height: 44px; font-size: 15px; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 4px 18px; }
.sidebar-brand strong { display: block; color: #fff; font-size: 15px; letter-spacing: .5px; }
.sidebar-brand small { color: #94a3b8; font-size: 11px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  text-align: left;
  padding: 10px 12px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(79, 70, 229, .35); }

.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(148, 163, 184, .18); padding-top: 14px; }
.me { display: flex; align-items: center; gap: 10px; padding: 0 4px 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; flex: 0 0 auto;
}
.me-info { min-width: 0; }
.me-info strong { display: block; color: #fff; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-info small { color: #94a3b8; font-size: 11px; }
.sidebar-actions { display: flex; gap: 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  padding: 20px 28px 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.topbar h2 { margin: 0; font-size: 20px; }
.topbar p { margin: 2px 0 0; font-size: 12px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.page-content { padding: 6px 28px 32px; }

/* ---------- 卡片 / 统计 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-card .label { font-size: 12px; color: var(--muted); }
.stat-card .value { font-size: 26px; font-weight: 650; margin-top: 4px; letter-spacing: .3px; }
.stat-card .hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
.stat-card.accent { border-color: #c7d2fe; background: linear-gradient(180deg, #eef2ff, #fff); }
.stat-card.accent .value { color: var(--brand); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-head h3 { margin: 0; font-size: 15px; }
.panel-body { padding: 16px 18px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input[type="search"], .toolbar input[type="text"], .toolbar select {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  outline: none;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }
.toolbar input[type="search"] { width: 220px; }
.toolbar select { min-width: 108px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: #f9fafb; color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
.table tbody tr:hover { background: #f9fafb; }
.table td.actions { white-space: nowrap; }
.table td .row-actions { display: flex; gap: 6px; }
.table .col-id { width: 64px; color: var(--muted); }
.table .col-time { color: var(--muted); white-space: nowrap; }
.table .title-cell { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: #f3f4f6; color: #4b5563; }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }

.vip-toggle-wrap { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.vip-toggle { width: 15px; height: 15px; margin: 0; cursor: pointer; accent-color: var(--brand); }
.vip-toggle:disabled { cursor: progress; opacity: 0.6; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.loading { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager .info { color: var(--muted); font-size: 12px; }
.pager .btns { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pager .jump { display: inline-flex; align-items: center; gap: 4px; }
.pager .jump-label { color: var(--muted); font-size: 12px; }
.pager .jump-input {
  width: 62px; height: 30px; padding: 0 6px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--text); font-size: 12px; font-family: inherit; text-align: center;
}

/* ---------- 公告列表（概览） ---------- */
.notice-list { display: flex; flex-direction: column; }
.notice-item { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.notice-item:last-child { border-bottom: none; }
.notice-item .head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.notice-item .head strong { font-size: 14px; }
.notice-item .meta { color: var(--muted); font-size: 12px; }
.notice-item .preview { color: #4b5563; font-size: 13px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 弹窗 ---------- */
.modal-host {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 18px;
  z-index: 60;
  overflow-y: auto;
}
.modal {
  width: 100%;
  max-width: 560px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
  animation: modal-in .18s ease-out;
}
@keyframes modal-in { from { transform: translateY(-8px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { border: none; background: transparent; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.modal-close:hover { background: #f3f4f6; color: var(--text); }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #fafafa; border-radius: 0 0 14px 14px; }
.modal .field input, .modal .field select, .modal .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
}
.modal .field input:disabled { background: #f3f4f6; color: var(--muted); }
.modal .field textarea { min-height: 180px; resize: vertical; line-height: 1.7; }
.modal .field input:focus, .modal .field select:focus, .modal .field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* 弹窗内复选框：压过 .modal .field input 的通用宽度/内边距，避免被拉成输入框导致错位 */
.modal .field.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  margin: 6px 0 14px;
}
.modal .field.checkbox > span { display: inline-block; margin-bottom: 0; }
.modal .field.checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  flex: 0 0 auto;
  accent-color: var(--brand);
}
.modal .field.checkbox input[type="checkbox"]:focus { box-shadow: none; }
/* 与左侧下拉框同一行时底部对齐 */
.form-row > .field.checkbox { align-self: end; margin-bottom: 16px; }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.field-hint { font-size: 11px; color: var(--muted); margin: 6px 0 0; }

/* ---------- 富文本编辑器 / 公告正文 ---------- */
.rich-editor { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.rich-editor:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }
.editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px 8px; background: #f8fafc; border-bottom: 1px solid var(--line); }
.editor-btn {
  min-width: 30px; height: 28px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: #374151; font-size: 12px; font-family: inherit; cursor: pointer;
  flex: 0 0 auto;
}
.editor-btn:hover { background: #eef2ff; color: var(--brand); }
.editor-btn:active { background: #e0e7ff; }
.editor-bold { font-weight: 700; }
.editor-italic { font-style: italic; }
.editor-underline { text-decoration: underline; }
.editor-strike { text-decoration: line-through; }
.editor-select {
  height: 28px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
  color: #374151; font-size: 12px; font-family: inherit; padding: 0 4px; cursor: pointer;
}
/* 压过 .modal .field select 的 width:100%，避免下拉框在工具栏内被挤压变形 */
.modal .field .editor-select {
  width: auto;
  min-width: 96px;
  flex: 0 0 auto;
  height: 28px;
  padding: 0 6px;
  font-size: 12px;
}
.editor-area {
  min-height: 220px; max-height: 46vh; overflow-y: auto; padding: 12px 14px;
  font-size: 13px; line-height: 1.8; color: var(--text); outline: none; word-break: break-word;
}
.editor-area:empty::before { content: attr(data-placeholder); color: #9ca3af; pointer-events: none; }
.editor-area p { margin: 0 0 10px; }
.editor-area h2 { font-size: 18px; margin: 14px 0 8px; }
.editor-area h3 { font-size: 15px; margin: 12px 0 8px; }
.editor-area ul, .editor-area ol { margin: 8px 0 10px; padding-left: 22px; }
.editor-area blockquote {
  margin: 10px 0; padding: 6px 12px; border-left: 3px solid var(--brand);
  background: #f8fafc; color: #4b5563;
}
.editor-area a { color: var(--brand); }

.rich-content { line-height: 1.8; color: #374151; word-break: break-word; }
.rich-content p { margin: 0 0 10px; }
.rich-content h1, .rich-content h2, .rich-content h3, .rich-content h4 { margin: 14px 0 8px; color: var(--text); }
.rich-content h2 { font-size: 17px; }
.rich-content h3 { font-size: 15px; }
.rich-content ul, .rich-content ol { margin: 8px 0 10px; padding-left: 22px; }
.rich-content blockquote {
  margin: 10px 0; padding: 6px 12px; border-left: 3px solid var(--brand);
  background: #f8fafc; color: #4b5563;
}
.rich-content a { color: var(--brand); }
.rich-content br { line-height: 1.8; }
.form-error-inline { color: var(--danger); font-size: 12px; margin: 0 0 10px; min-height: 18px; }

/* ---------- 云端缓存详情 ---------- */
.cache-detail { display: grid; grid-template-columns: 84px 1fr; gap: 10px 12px; margin: 0 0 8px; font-size: 13px; }
.cache-detail dt { color: var(--muted); }
.cache-detail dd { margin: 0; word-break: break-word; white-space: pre-wrap; line-height: 1.65; }

/* ---------- 提示 ---------- */
.toast-host { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  min-width: 200px;
  max-width: 420px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  background: #111827;
  color: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .25);
  animation: toast-in .18s ease-out;
}
.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }
@keyframes toast-in { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { position: static; height: auto; width: 100%; flex: none; padding: 12px; }
  .sidebar-brand { padding-bottom: 10px; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav-item { flex: 0 0 auto; }
  .sidebar-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding-top: 10px; }
  .me { padding-bottom: 0; }
  .topbar { padding: 16px 18px 10px; flex-direction: column; align-items: flex-start; }
  .page-content { padding: 4px 14px 28px; }
  .form-row { grid-template-columns: 1fr; }
  .toolbar input[type="search"] { width: 100%; }
  .modal-host { padding: 20px 12px; }
}
