:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1f2329;
  --text-muted: #6b7280;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.nav .brand { font-weight: 700; color: var(--text); font-size: 17px; }
.nav .brand:hover { text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 16px; }
.nav-links a { color: var(--text); }
.nav-links a:hover { color: var(--primary); text-decoration: none; }
.nav-user { color: var(--text-muted); font-size: 14px; }

.container { max-width: 960px; margin: 0 auto; padding: 20px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.page-head h1 { margin: 0; font-size: 22px; }

h2 { font-size: 17px; margin: 20px 0 12px; }

.muted { color: var(--text-muted); font-size: 14px; }
.strong { font-weight: 600; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { margin-top: 0; }

.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
}

.banner {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}
.banner-info { background: #eef4ff; color: #1d4ed8; border: 1px solid #d6e4ff; }
.banner-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* 表单 */
label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--text-muted); }
input, select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus { outline: none; border-color: var(--primary); }

.form-card { max-width: 560px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

/* 按钮 */
.btn {
  display: inline-block;
  padding: 9px 16px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #f1f3f5; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.link-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 14px; padding: 0;
}
.link-btn:hover { color: var(--danger); }

.inline { display: inline; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* 登录/注册 */
.auth-card {
  max-width: 380px;
  margin: 60px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.auth-card h1 { margin: 0 0 20px; text-align: center; }

/* 表格 */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.table thead th { background: #fafbfc; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 8px; white-space: nowrap; }

/* 课表网格 */
.timetable { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.timetable th, .timetable td { border: 1px solid var(--border); padding: 6px; vertical-align: top; }
.timetable thead th { background: #fafbfc; color: var(--text-muted); text-align: center; }
.timetable .corner { width: 90px; }
.period-cell {
  background: #fafbfc; color: var(--text-muted); font-weight: 600; text-align: center; width: 90px;
}
.period-time { display: block; font-weight: 400; font-size: 11px; color: var(--text-muted); }
.course-cell { background: #eef4ff; border-left: 3px solid var(--primary); }
.empty-cell { background: #fff; }
.course-name { font-weight: 700; margin-bottom: 2px; }
.course-meta { color: var(--text-muted); font-size: 12px; }

/* 节次管理 */
.period-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.period-edit { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.period-edit input { width: auto; margin-top: 0; }
.period-edit input[name="name"] { width: 160px; }
.period-edit input[type="time"] { width: 110px; }
.period-edit .order { color: var(--text-muted); font-size: 13px; min-width: 20px; }
.period-edit .sep { color: var(--text-muted); }

/* 订阅链接 */
.feed-url { display: flex; gap: 8px; margin: 12px 0; }
.feed-url input { margin-top: 0; font-family: monospace; }

@media (max-width: 640px) {
  .two-col { grid-template-columns: 1fr; }
  .nav-links { gap: 10px; font-size: 14px; }
  .timetable { font-size: 12px; }
}
