:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --brand: #3b82f6;
  --brand-hover: #2563eb;
  --accent: #f59e0b;
  --line: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #f8fafc 0%, #f1f5f9 100%);
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1200px;
  margin: 32px auto 80px;
  padding: 0 24px;
}

/* ==== 去框化群組標題 ==== */
.group-title {
  display: flex;
  align-items: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 24px 0;
  position: relative;
  padding-left: 14px;
}

.group-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 22px;
  background-color: var(--brand);
  border-radius: 4px;
}

/* ==== 控制台區塊 (Form) ==== */
.control-panel {
  margin-bottom: 32px;
}

.card {
  background: #ffffff;
  border-radius: 16px;
  padding: 24px 28px;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.04), 0 0 3px rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

/* ==== 頁籤優化 ==== */
.review-toolbar {
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.tabs {
  display: flex;
  gap: 32px;
  overflow-x: auto;
}

.tab {
  padding: 12px 4px;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  white-space: nowrap;
}

.tab:hover {
  color: var(--brand);
}

.tab.is-active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.form {
  display: grid;
  gap: 20px;
}

.grid.g-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 6px;
}

.lbl {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.span-2 {
  grid-column: span 2;
}

input,
select.modern-select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.7);
}

input:focus,
select.modern-select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: #fff;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

/* ==== Buttons ==== */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.btn.primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.btn.primary:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.btn.ghost {
  background: transparent;
}

.btn.ghost:hover {
  background: rgba(0, 0, 0, 0.05);
}

.btn-large {
  padding: 10px 24px;
  font-size: 16px;
}

.btn.danger-ghost {
  color: #dc2626;
  background: transparent;
  border-color: transparent;
}

.btn.danger-ghost:hover {
  background: #fee2e2;
}

/* ==== 現代化數據資料表 ==== */
.data-grid-section {
  margin-top: 40px;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.modern-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.role-badge.teacher {
  background-color: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.role-badge.reviewer {
  background-color: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.role-badge.maintainer {
  background-color: #fff1f2;
  color: #e11d48;
  border: 1px solid #fecdd3;
}

.role-badge select.role-select {
  background: transparent !important;
  border: none !important;
  font: inherit !important;
  color: inherit !important;
  font-weight: 700 !important;
  cursor: pointer;
  outline: none !important;
  padding: 0 4px 0 0 !important;
  margin: 0 !important;
  width: auto !important;
  min-width: unset !important;
}

/* ==== Buttons (Extended) ==== */
.btn.ghost {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #475569;
  padding: 6px 12px;
  font-size: 13px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn.ghost:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #2563eb;
}

.btn.danger-ghost {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #64748b;
  padding: 6px 12px;
  font-size: 13px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn.danger-ghost:hover {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #e11d48;
}

.table-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.2s;
}

.table-input:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.table-input:focus {
  outline: none;
  background: #fff;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.modern-table th {
  background: #f1f5f9;
  color: #334155;
  font-weight: 700;
  text-align: left;
  padding: 16px;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

.modern-table td {
  padding: 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  transition: background 0.2s;
}

.modern-table tbody tr:hover td {
  background: #f8fafc;
}

.modern-table tbody tr:last-child td {
  border-bottom: none;
}

.modern-table td input,
.modern-table td select {
  width: 100%;
  min-width: 140px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid transparent;
}

.modern-table td input:focus,
.modern-table td select:focus {
  background: #fff;
  border-color: var(--brand);
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.msg {
  min-height: 20px;
  font-size: 14px;
  font-weight: 600;
  color: #10b981;
  /* Success default */
}

.msg.error {
  color: #ef4444;
}

/* Tab logic styling handled by JS or inline HTML */
.tab-content {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.type-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.type-badge.local {
  background-color: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}

.type-badge.google {
  background-color: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

@media (max-width: 900px) {
  .grid.g-2 {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}