:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #eab308;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
.container { max-width: 960px; margin: 0 auto; padding: 0 1rem; width: 100%; min-width: 0; }
.main-content { flex: 1; padding: 1.5rem 0; }

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; }
.logo { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.1rem; }
.site-header nav a { margin-right: 1rem; color: var(--text-muted); text-decoration: none; }
.site-header nav a:hover { color: var(--primary); }
.btn-link {
  background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: inherit;
}
.btn-link:hover { color: var(--error); }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 0.75rem 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Auth */
.auth-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}
.auth-card h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.auth-subtitle { color: var(--text-muted); margin: 0 0 1.5rem; font-size: 0.9rem; }
.auth-form label { display: block; margin-bottom: 1rem; }
.auth-form label span { display: block; margin-bottom: 0.35rem; font-size: 0.9rem; color: var(--text-muted); }
.auth-form input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
.auth-form input:focus { outline: none; border-color: var(--primary); }
.auth-form .btn { margin-top: 0.5rem; }
.auth-divider { text-align: center; margin: 1rem 0 0.75rem; font-size: 0.85rem; }
.auth-divider.muted { color: var(--text-muted); }
.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 1rem;
  margin-top: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 1rem;
  cursor: pointer;
  box-sizing: border-box;
}
.btn-google:hover { background: rgba(255,255,255,0.06); border-color: var(--text-muted); }
.btn-google-icon { flex-shrink: 0; vertical-align: middle; }

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #3d4f6a; }
.btn-block { width: 100%; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.85rem; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  min-width: 0;
  overflow: hidden;
}
.card h2 { margin: 0 0 1rem; font-size: 1.1rem; }
.quota-card .quota-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.quota-card .quota-value span { font-size: 1rem; font-weight: 400; color: var(--text-muted); }

/* Forms */
.form-inline { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.form-inline input[type="number"] { width: 100px; padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.form-grid { display: grid; gap: 1rem; max-width: 400px; }
.form-grid label { display: block; }
.form-grid label input, .form-grid label textarea {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.form-grid textarea { resize: vertical; min-height: 60px; }
.form-compact { flex-wrap: wrap; }
.form-compact input { width: 90px; }

/* Table */
.table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 480px; }
.data-table th, .data-table td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--text-muted); font-weight: 600; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.03); }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-success { background: rgba(34, 197, 94, 0.15); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.3); }
.alert-error { background: rgba(239, 68, 68, 0.15); color: var(--error); border: 1px solid rgba(239, 68, 68, 0.3); }

/* Status */
.status { padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.85rem; white-space: nowrap; }
.status-pending { background: rgba(234, 179, 8, 0.2); color: var(--warning); }
.status-approved { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.status-rejected { background: rgba(239, 68, 68, 0.2); color: var(--error); }
.status-deleted { background: rgba(139, 148, 158, 0.25); color: var(--text-muted); }

.muted { color: var(--text-muted); font-size: 0.9rem; }
h1 { margin: 0 0 1.5rem; font-size: 1.5rem; }

.form-hint { display: block; margin-top: 0.25rem; font-size: 0.8rem; color: var(--text-muted); }
.link-download { color: var(--primary); text-decoration: none; }
.link-download:hover { text-decoration: underline; }

/* 学生管理工具栏 */
.student-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.student-toolbar input[type="text"] {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  width: 200px;
}
.student-toolbar .per-page { color: var(--text-muted); font-size: 0.9rem; }
.student-toolbar select {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.student-batch-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.student-batch-actions input[type="number"] { width: 80px; padding: 0.4rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }

/* 文件管理 */
.files-toolbar { margin-bottom: 1rem; }
.files-toolbar select { padding: 0.4rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.files-batch-actions { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.data-table td.actions { white-space: nowrap; }
.data-table td.actions .btn { margin-right: 0.25rem; }
.data-table .cell-desc { max-width: 12em; word-break: break-word; }
.data-table .cell-filename { max-width: 14em; word-break: break-all; }
.inline-form { display: inline; }
.replace-file-form { display: inline-flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.replace-file-form input[type="file"] { font-size: 0.8rem; max-width: 140px; }

/* 小屏：表格在容器内横向滚动，操作列允许换行减少宽度 */
@media (max-width: 768px) {
  .data-table { min-width: 520px; font-size: 0.85rem; }
  .data-table th, .data-table td { padding: 0.5rem 0.5rem; }
  .data-table td.actions { white-space: normal; }
  .data-table td.actions .btn { margin-bottom: 0.25rem; }
  .replace-file-form { flex-direction: column; align-items: flex-start; }
  .replace-file-form input[type="file"] { max-width: 100%; min-width: 0; }
}
.btn-danger { background: rgba(239, 68, 68, 0.25); color: var(--error); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.4); }

/* 分页 */
.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.pagination .page-info { color: var(--text-muted); font-size: 0.9rem; }
.pagination a { text-decoration: none; }

/* 弹窗 */
.modal { display: none; position: fixed; inset: 0; z-index: 100; align-items: center; justify-content: center; padding: 1rem; }
.modal.modal-open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); cursor: pointer; }
.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
}
.modal-content h3 { margin: 0 0 1rem; font-size: 1.1rem; }
.modal-content label { display: block; margin-bottom: 0.75rem; }
.modal-content label input {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.modal-actions { display: flex; gap: 0.5rem; margin-top: 1.25rem; justify-content: flex-end; }

/* 模型共享库 */
.breadcrumb { margin-bottom: 1rem; color: var(--text-muted); font-size: 0.9rem; }
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .current { color: var(--text); }
.library-toolbar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.library-toolbar .form-inline input[type="text"] { min-width: 160px; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.library-toolbar .upload-form input[type="file"] { font-size: 0.85rem; }
.library-bulk-actions { margin-top: 0.75rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
