:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic",
    "Segoe UI", Roboto, sans-serif;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 16px;
  line-height: 1.5;
}

/* ---------- 제출 카드 ---------- */
.card {
  width: 100%;
  max-width: 460px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}

.card-head { margin-bottom: 24px; }
.school-title { margin: 0 0 6px; font-size: 27px; font-weight: 800; color: var(--brand-dark); letter-spacing: -0.5px; }
.card-head h1 { margin: 0 0 6px; font-size: 20px; }
.subtitle { margin: 0; color: var(--muted); font-size: 14px; }

.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.hint { color: var(--muted); font-weight: 400; }

select, input[type="text"], input[type="password"], input[type="file"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
}
select:focus, input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }

.file-hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }

button {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
button:hover { background: var(--brand-dark); }
button:disabled { opacity: 0.6; cursor: default; }

.message { margin: 14px 0 0; font-size: 14px; text-align: center; min-height: 20px; }
.message.error { color: var(--danger); }
.message.ok { color: var(--ok); font-weight: 600; }

/* ---------- 관리자 페이지 ---------- */
.admin-wrap { width: 100%; max-width: 1000px; }

.login-card { max-width: 380px; margin: 60px auto; }

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.admin-head h1 { margin: 0; font-size: 22px; }
.admin-head .actions { display: flex; gap: 8px; }
.admin-head button { width: auto; padding: 9px 14px; font-size: 14px; }

.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: #f3f4f6; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar select, .toolbar input {
  width: auto;
  min-width: 140px;
  flex: 0 0 auto;
}
.toolbar button { width: auto; padding: 9px 14px; font-size: 14px; flex: 0 0 auto; }
.toolbar .count { margin-left: auto; color: var(--muted); font-size: 14px; }

.table-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f9fafb; font-weight: 600; color: var(--muted); position: sticky; top: 0; }
tbody tr:hover { background: #f9fafb; }
td.file a { color: var(--brand); text-decoration: none; }
td.file a:hover { text-decoration: underline; }

.link-btn {
  background: none; border: none; color: var(--danger);
  cursor: pointer; font-size: 13px; padding: 4px 6px; width: auto;
}
.link-btn:hover { text-decoration: underline; background: none; }

.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- 제출현황 현황판 ---------- */
.status-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}
.grade-tabs { display: inline-flex; gap: 4px; background: #eef1f5; padding: 4px; border-radius: 10px; }
.gtab {
  width: auto;
  padding: 7px 16px;
  background: none;
  border: none;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.gtab:hover { background: rgba(255, 255, 255, 0.6); }
.gtab.active { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1); }
.status-summary { color: var(--muted); font-size: 14px; }
.status-toolbar .btn-secondary { width: auto; padding: 9px 14px; font-size: 14px; }
.status-toolbar #download-selected-btn { margin-left: auto; }

.status-group { margin-bottom: 24px; }
.status-group h3 { margin: 0 0 12px; font-size: 16px; }
.status-group h3 .count { color: var(--muted); font-weight: 500; font-size: 14px; margin-left: 4px; }

.badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.badge.ok { background: var(--ok); color: #fff; }
.badge.no { background: #e5e7eb; color: #9ca3af; }

.status-table th.c-check, .status-table td.c-check { width: 40px; text-align: center; }
.status-table th.c-check input, .status-table td.c-check input { cursor: pointer; }
.status-table th.c-status, .status-table td.c-status { width: 84px; }
.status-table .subj-name { font-weight: 600; }
.status-table td.muted { color: var(--muted); }
.status-table a { color: var(--brand-dark); text-decoration: none; word-break: break-all; }
.status-table a:hover { text-decoration: underline; }
/* 미제출 행 = 음영 처리 */
.status-table tr.missing td { background: #f9fafb; }
.status-table tr.missing .subj-name { color: #9ca3af; font-weight: 500; }
.status-table tbody tr:hover td { background: #f1f5f9; }

/* ---------- 탭 ---------- */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.tab {
  width: auto;
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  border-radius: 0;
}
.tab:hover { background: none; color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- 과목 관리 ---------- */
.panel-desc { margin: 0 0 16px; }

.subject-add {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 20px;
}
.subject-add select, .subject-add input { width: auto; }
.subject-add input { min-width: 200px; flex: 1 1 200px; }
.subject-add button { width: auto; padding: 11px 18px; font-size: 14px; }
.inline-msg { font-size: 13px; }
.inline-msg.error { color: var(--danger); }
.inline-msg.ok { color: var(--ok); }

.subject-grade-group {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.subject-grade-group h3 { margin: 0 0 12px; font-size: 16px; }
.subject-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.subject-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  background: #f3f4f6;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 14px;
}
.subject-chip button {
  width: 20px;
  height: 20px;
  padding: 0;
  line-height: 1;
  border-radius: 50%;
  background: #e5e7eb;
  color: var(--muted);
  font-size: 15px;
}
.subject-chip button:hover { background: var(--danger); color: #fff; }
.subject-empty { color: var(--muted); font-size: 14px; }

@media (max-width: 520px) {
  th, td { padding: 10px; }
}
