:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d7dee7;
  --line-strong: #b8c3cf;
  --text: #1b2733;
  --muted: #687789;
  --primary: #195aa5;
  --primary-dark: #123f73;
  --primary-soft: #e7f0fb;
  --danger: #b42318;
  --danger-soft: #fff1ef;
  --success: #10713b;
  --success-soft: #e7f7ed;
  --warning: #9a6700;
  --warning-soft: #fff7df;
  --sidebar: #142235;
  --sidebar-muted: #9badc2;
  font-family:
    "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  background: var(--sidebar);
  color: #fff;
  padding: 24px 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 6px 28px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--primary);
  border-radius: 8px;
  font-size: 24px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 22px;
}

.brand small {
  margin-top: 2px;
  color: var(--sidebar-muted);
  line-height: 1.35;
}

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

.nav-item {
  width: 100%;
  border-radius: 6px;
  color: #d6e0eb;
  padding: 13px 14px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.content {
  min-width: 0;
  padding: 28px;
  overflow-x: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card {
  padding: 18px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
}

.panel {
  margin-bottom: 16px;
  overflow: hidden;
}

.panel-head {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head.stacked {
  align-items: flex-start;
}

.panel-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

input:focus,
select:focus {
  outline: 2px solid rgba(25, 90, 165, 0.2);
  border-color: var(--primary);
}

button,
.button {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  background: var(--primary);
  color: #fff;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--text);
}

.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #ffd1cc;
}

.toolbar,
.student-form,
.inline-form {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  color: #425466;
  font-size: 13px;
}

tr:last-child td {
  border-bottom: 0;
}

.student-form {
  padding: 18px;
}

.student-form label {
  min-width: 220px;
}

.action-col {
  width: 92px;
}

.row-button {
  min-height: 30px;
  padding: 5px 9px;
  background: #fff;
  border-color: var(--line-strong);
  color: var(--text);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.summary-strip div {
  border: 1px solid var(--line);
  background: #fbfcfe;
  border-radius: 8px;
  padding: 14px;
}

.summary-strip span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-strip strong {
  display: block;
  margin-top: 7px;
  font-size: 26px;
}

.attendance-wide-wrap {
  max-height: calc(100vh - 260px);
}

.attendance-table {
  min-width: 900px;
  table-layout: fixed;
}

.attendance-table .student-no-col,
.attendance-table .student-name-col {
  width: 112px;
}

.attendance-table .period-col {
  width: 74px;
}

.attendance-table .total-col {
  width: 96px;
}

.attendance-table th,
.attendance-table td {
  text-align: center;
}

.attendance-table .day-head {
  border-left: 2px solid var(--line-strong);
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  background: #fff;
}

th.sticky-col {
  z-index: 4;
  background: #f8fafc;
}

.sticky-col.second {
  left: 112px;
}

.attendance-table th:nth-child(1),
.attendance-table td:nth-child(1) {
  min-width: 112px;
}

.attendance-table th:nth-child(2),
.attendance-table td:nth-child(2) {
  min-width: 112px;
}

.period-select {
  width: 100%;
  min-width: 74px;
  min-height: 40px;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 6px 8px;
  cursor: pointer;
}

.attendance-cell {
  padding: 0;
  background: #fff;
}

.attendance-cell:hover {
  background: var(--primary-soft);
}

.date-cell {
  display: grid;
  gap: 4px;
  justify-items: center;
  color: var(--text);
}

.date-cell input {
  width: 132px;
  min-height: 32px;
  padding: 4px 6px;
}

.date-cell span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.is-saving {
  outline: 2px solid rgba(25, 90, 165, 0.28);
}

.grades-table {
  min-width: 980px;
}

.grade-input {
  width: 76px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 800;
}

.badge.good {
  background: var(--success-soft);
  color: var(--success);
}

.badge.mid {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge.low {
  background: var(--danger-soft);
  color: var(--danger);
}

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

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 220px minmax(680px, 1fr);
  }

  .sidebar {
    padding: 16px;
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 18px;
  }

  .topbar {
    display: block;
  }

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

@media (max-width: 560px) {
  .metric-grid,
  .summary-strip {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }

  .panel-head,
  .student-form {
    display: grid;
  }

  .student-form label,
  .toolbar label {
    width: 100%;
    min-width: 0;
  }
}
