@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;600;700&display=swap');

:root {
  --blue-header: #5ba3d9;
  --blue-nav: #4a90c9;
  --blue-light: #d6eaf8;
  --blue-bg: #e8f4fc;
  --blue-dark: #2d6da3;
  --red: #c81623;
  --orange: #f39800;
  --orange-hover: #e08800;
  --white: #ffffff;
  --text: #333333;
  --text-muted: #666666;
  --text-light: #999999;
  --border: #dddddd;
  --border-input: #cccccc;
  --success: #52a852;
  --warning: #f39800;
  --danger: #c81623;
  --footer-bg: #3d3d3d;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --sidebar-w: 200px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  background: var(--blue-bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
}

a { color: var(--blue-dark); text-decoration: none; }
a:hover { color: var(--red); }

/* ===== Top Bar ===== */
.top-bar { background: var(--white); border-bottom: 1px solid #eee; font-size: 12px; color: var(--text-muted); }
.top-bar-inner { max-width: 1200px; margin: 0 auto; padding: 0 20px; display: flex; justify-content: space-between; align-items: center; height: 32px; }
.top-bar a { color: var(--red); }
.top-bar-right a { color: var(--text-muted); }

/* ===== Brand Header ===== */
.brand-header { background: var(--blue-header); padding: 14px 0; }
.brand-inner { max-width: 1200px; margin: 0 auto; padding: 0 20px; display: flex; justify-content: space-between; align-items: center; }
.brand-logo { display: flex; align-items: center; gap: 10px; color: var(--white); }
.brand-logo:hover { color: var(--white); }
.brand-logo-icon {
  width: 40px; height: 40px; background: var(--white); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--blue-nav); font-weight: 700; font-size: 14px;
}
.brand-logo-text strong { font-size: 18px; letter-spacing: 1px; }
.brand-logo-text span { font-size: 11px; opacity: 0.85; display: block; }
.brand-badge { background: rgba(255,255,255,0.2); padding: 4px 12px; font-size: 12px; color: var(--white); border-radius: 2px; }

/* ===== Admin Layout ===== */
.admin-layout { display: flex; min-height: calc(100dvh - 120px); }
.sidebar {
  width: var(--sidebar-w); background: var(--blue-nav); flex-shrink: 0;
  display: flex; flex-direction: column;
}
.sidebar-nav { flex: 1; padding: 8px 0; }
.nav-section-title {
  padding: 8px 16px 4px; font-size: 11px; color: rgba(255,255,255,0.5);
  text-transform: uppercase; letter-spacing: 1px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  color: rgba(255,255,255,0.85); font-size: 13px; transition: background 0.2s; min-height: 40px;
}
.nav-item:hover { background: rgba(0,0,0,0.1); color: var(--white); }
.nav-item.active { background: rgba(0,0,0,0.2); color: var(--white); font-weight: 600; border-left: 3px solid var(--orange); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.15); }
.user-info { display: flex; align-items: center; gap: 8px; color: var(--white); font-size: 13px; }
.user-avatar {
  width: 28px; height: 28px; background: rgba(255,255,255,0.2); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
}

.main { flex: 1; display: flex; flex-direction: column; }
.topbar {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 48px; display: flex; align-items: center; justify-content: space-between;
}
.topbar h1 { font-size: 15px; font-weight: 600; color: var(--text); }
.topbar-actions { display: flex; gap: 12px; align-items: center; font-size: 12px; color: var(--text-muted); }
.content { padding: 20px 24px; flex: 1; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 20px; font-size: 13px; font-weight: 500; border: none;
  cursor: pointer; transition: all 0.2s; border-radius: 2px; min-height: 34px;
}
.btn-primary { background: var(--orange); color: var(--white); }
.btn-primary:hover { background: var(--orange-hover); }
.btn-secondary { background: var(--blue-nav); color: var(--white); }
.btn-secondary:hover { background: var(--blue-dark); }
.btn-outline { background: var(--white); color: var(--blue-nav); border: 1px solid var(--blue-nav); }
.btn-outline:hover { background: var(--blue-light); }
.btn-sm { padding: 4px 12px; font-size: 12px; min-height: 28px; }

/* ===== Stats ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--white); border: 1px solid var(--border); padding: 16px 20px;
  border-top: 3px solid var(--blue-nav);
}
.stat-card:nth-child(2) { border-top-color: var(--success); }
.stat-card:nth-child(3) { border-top-color: var(--danger); }
.stat-card:nth-child(4) { border-top-color: var(--orange); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-change { font-size: 12px; margin-top: 4px; }
.stat-up { color: var(--success); }
.stat-down { color: var(--danger); }

/* ===== Charts ===== */
.charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-bottom: 20px; }
.chart-card { background: var(--white); border: 1px solid var(--border); padding: 16px 20px; }
.chart-title {
  font-size: 14px; font-weight: 600; margin-bottom: 16px; color: var(--text);
  padding-bottom: 8px; border-bottom: 2px solid var(--blue-nav);
}
.chart-canvas { width: 100%; height: 240px; }

/* ===== Panel ===== */
.panel { background: var(--white); border: 1px solid var(--border); margin-bottom: 16px; }
.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px; background: var(--blue-light); border-bottom: 1px solid var(--border);
}
.panel-title { font-size: 14px; font-weight: 600; color: var(--text); }
.panel-body { padding: 20px; }

/* ===== Table ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 10px 14px; text-align: left; border: 1px solid var(--border); }
.data-table th { background: var(--blue-light); font-weight: 600; color: var(--text); }
.data-table tr:nth-child(even) td { background: #fafafa; }
.data-table tr:hover td { background: var(--blue-bg); }

/* ===== Form ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border-input);
  font-family: inherit; font-size: 13px; background: var(--white); color: var(--text); min-height: 36px;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--blue-nav); }
.form-textarea { min-height: 80px; resize: vertical; }
.form-hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }

.range-group { display: flex; align-items: center; gap: 10px; }
.range-group input[type="range"] { flex: 1; accent-color: var(--blue-nav); }
.range-value { font-size: 14px; font-weight: 600; color: var(--blue-nav); min-width: 40px; text-align: right; }

/* ===== Status ===== */
.status { display: inline-block; padding: 2px 8px; font-size: 12px; border-radius: 2px; }
.status-active, .status-done { background: #e8f5e8; color: var(--success); }
.status-inactive, .status-pending { background: #fff8e8; color: var(--warning); }
.risk-high { color: var(--danger); font-weight: 600; }
.risk-medium { color: var(--warning); font-weight: 600; }
.risk-low { color: var(--success); font-weight: 600; }

/* ===== Filters ===== */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-input, .filter-select {
  padding: 7px 12px; border: 1px solid var(--border-input); font-size: 13px;
  background: var(--white); min-height: 34px;
}

/* ===== Toggle ===== */
.toggle { position: relative; width: 40px; height: 22px; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: #ccc; cursor: pointer; border-radius: 22px; transition: 0.2s;
}
.toggle-slider::before {
  content: ''; position: absolute; width: 16px; height: 16px;
  left: 3px; bottom: 3px; background: var(--white); border-radius: 50%; transition: 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--blue-nav); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ===== Template Preview ===== */
.template-preview {
  border: 1px solid var(--border); background: #fafafa;
  padding: 24px; min-height: 360px; position: relative;
}
.template-preview .watermark {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%) rotate(-30deg);
  font-size: 36px; color: rgba(0,0,0,0.04); pointer-events: none; letter-spacing: 4px;
}
.template-preview .stamp {
  position: absolute; bottom: 30px; right: 30px;
  width: 70px; height: 70px; border: 3px solid var(--red); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--red); transform: rotate(-15deg); opacity: 0.7; text-align: center;
}

/* ===== Login Page (CNKI style) ===== */
.login-page {
  min-height: 100dvh; display: flex; flex-direction: column; background: var(--blue-bg);
}
.login-main { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; }
.login-card {
  width: 100%; max-width: 520px; background: var(--white);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.login-card-body { padding: 32px 40px 40px; }
.login-card-body h2 { display: none; }

/* CNKI Tabs */
.cnki-tabs { display: flex; background: var(--blue-nav); }
.cnki-tab {
  flex: 1; padding: 12px 8px; text-align: center; font-size: 13px;
  color: var(--white); background: var(--blue-nav); border: none; cursor: pointer; min-height: 44px;
}
.cnki-tab.active { background: var(--white); color: var(--red); font-weight: 600; }
.cnki-tab:hover:not(.active) { background: var(--blue-dark); }

.input-group { display: flex; border: 1px solid var(--border-input); margin-bottom: 16px; }
.input-group-icon {
  width: 40px; display: flex; align-items: center; justify-content: center;
  background: #f5f5f5; border-right: 1px solid var(--border-input); color: var(--text-light);
}
.input-group-icon svg { width: 18px; height: 18px; }
.input-group input {
  flex: 1; border: none; padding: 10px 12px; font-size: 14px; outline: none; min-height: 40px;
}
.input-row { display: flex; gap: 8px; margin-bottom: 16px; }
.input-row .input-group { flex: 1; margin-bottom: 0; }

/* ===== Footer ===== */
.site-footer { background: var(--footer-bg); color: #aaa; padding: 20px 0; font-size: 12px; line-height: 1.8; }
.site-footer a { color: #aaa; }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid, .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .admin-layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .stats-grid { grid-template-columns: 1fr; }
}
