:root {
  --bg: #f4f5f7;
  --sidebar-bg: #1f2430;
  --sidebar-text: #b6bbc9;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: #323a4d;
  --primary: #4f6df5;
  --primary-hover: #3f59d4;
  --danger: #e5484d;
  --text: #1a1d29;
  --text-dim: #6b7280;
  --border: #e3e5ea;
  --card-bg: #ffffff;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 200px;
  flex: 0 0 auto;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 16px 0;
}

.sidebar .brand {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 0 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 8px;
}

.sidebar .group-title {
  padding: 14px 18px 4px;
  font-size: 11px;
  letter-spacing: .05em;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
}

.sidebar a {
  display: block;
  padding: 8px 18px;
  color: var(--sidebar-text);
  font-size: 13.5px;
}

.sidebar a:hover {
  color: #fff;
  text-decoration: none;
}

.sidebar a.active {
  color: var(--sidebar-active);
  background: var(--sidebar-active-bg);
  font-weight: 600;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.topbar .page-title {
  font-size: 16px;
  font-weight: 700;
}

.topbar .right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.unpublished-badge {
  font-size: 12px;
  color: #b45309;
  background: #fef3c7;
  padding: 4px 10px;
  border-radius: 999px;
}

.published-at {
  font-size: 12px;
  color: var(--text-dim);
}

.content {
  padding: 20px 24px;
  flex: 1 1 auto;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}

.card h2 {
  font-size: 15px;
  margin: 0 0 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.btn:hover { background: var(--primary-hover); text-decoration: none; color: #fff; }

.btn-secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: #f0f1f3; color: var(--text); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #c73338; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th { color: var(--text-dim); font-weight: 600; font-size: 12.5px; }

/* 报表/日志页的数据表头悬浮：列表往下滚动时表头固定在视口顶部不跟着滚走 */
.table-sticky-header th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--card-bg);
}

tr:hover td { background: #fafbfc; }

.form-row {
  margin-bottom: 14px;
}

.form-row label {
  display: block;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 5px;
}

.form-row input[type=text],
.form-row input[type=number],
.form-row input[type=password],
.form-row input[type=url],
.form-row input[type=color],
.form-row select,
.form-row textarea {
  width: 100%;
  max-width: 420px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

.form-row textarea { resize: vertical; min-height: 70px; }

.form-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: #eef0f3;
  display: inline-block;
}

/* banner 素材是 600:340 的横图，不能用图标那种 40x40 方形缩略图，
   否则看不出banner实际构图，这里按真实比例整张显示 */
.thumb-banner {
  width: 160px;
  aspect-ratio: 600 / 340;
  border-radius: 8px;
  object-fit: cover;
  background: #eef0f3;
  display: inline-block;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
}

.badge-on { background: #dcfce7; color: #15803d; }
.badge-off { background: #f3f4f6; color: #6b7280; }

.flash {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13.5px;
}

.flash-success { background: #dcfce7; color: #15803d; }
.flash-error { background: #fee2e2; color: #b91c1c; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-box {
  width: 320px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
}

.login-box h1 {
  font-size: 17px;
  margin: 0 0 18px;
}

.inline-form { display: inline; }

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tag-list a {
  padding: 6px 12px;
  border-radius: 999px;
  background: #eef0f3;
  color: var(--text);
  font-size: 12.5px;
}

.tag-list a.active {
  background: var(--primary);
  color: #fff;
}

/* ---------- 报表：筛选栏 / 统计卡片 / 简易趋势图 / 分页 ---------- */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  align-items: end;
}

.filter-grid .form-row {
  margin-bottom: 0;
}

.filter-grid-loose {
  gap: 40px;
}

.filter-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.date-presets a {
  padding: 3px 10px;
  border-radius: 999px;
  background: #eef0f3;
  color: var(--text-dim);
  font-size: 12px;
}

.date-presets a.active {
  background: var(--primary);
  color: #fff;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card .stat-title {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-card .stat-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}

.stat-card .stat-sub.up { color: #15803d; }
.stat-card .stat-sub.down { color: var(--danger); }

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 160px;
  padding-top: 10px;
}

.chart-bars .bar-wrap {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  min-width: 0;
}

.chart-bars .bar {
  width: 100%;
  max-width: 28px;
  background: linear-gradient(180deg, var(--primary), var(--primary-hover));
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.chart-bars .bar-label {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
}

.pagination .pages {
  display: flex;
  gap: 4px;
}

.pagination .pages a,
.pagination .pages span {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text);
}

.pagination .pages .active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

th.sortable { cursor: pointer; }
th.sortable a { color: inherit; }
th.sortable:hover { color: var(--text); }

/* ---------- 弹窗（新增/编辑用），通用 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 20, 29, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-overlay[hidden] { display: none; }

.modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  width: 480px;
  max-width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,.35);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h2 { margin: 0; font-size: 15px; }

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 6px;
}

.modal-close:hover { color: var(--text); }

/* ---------- 列表顶部搜索栏 ---------- */
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.list-toolbar .search-form {
  display: flex;
  gap: 8px;
}

.list-toolbar input[type=text] {
  width: 240px;
  max-width: 60vw;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
}

/* ---------- 可搜索下拉（.ss 组件，见 admin.js） ---------- */
.ss {
  position: relative;
  display: inline-block;
  min-width: 180px;
}

.ss-trigger {
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ss-trigger:hover { border-color: #c7cad1; }
.ss-invalid .ss-trigger { border-color: #e5484d; }

.ss-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 60;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 24px -8px rgba(0,0,0,.2);
  width: 260px;
  max-width: 80vw;
  overflow: hidden;
}

.ss-panel[hidden] { display: none; }

.ss-search {
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  box-sizing: border-box;
}

.ss-search:focus { outline: none; }

.ss-options {
  max-height: 220px;
  overflow-y: auto;
}

.ss-option {
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
}

.ss-option:hover { background: #f0f1f3; }
.ss-option[hidden] { display: none; }
