:root {
  color-scheme: light;
  --font-ui: "Pretendard", "Pretendard Variable", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Segoe UI", sans-serif;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-base: 15px;
  --text-lg: 17px;
  --text-xl: 20px;
  --text-title: 30px;
  --ink: #17202a;
  --muted: #64707d;
  --line: #d8e0e8;
  --paper: #ffffff;
  --soft: #f3f6f9;
  --nav: #102331;
  --nav-2: #163447;
  --accent: #0f8b8d;
  --accent-dark: #086b6d;
  --warn: #c87920;
  --danger: #bb3e3e;
  --success: #22835f;
  --shadow: 0 18px 45px rgba(31, 45, 61, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--soft);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: 1.5;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: linear-gradient(135deg, var(--nav), #24475a);
}

.login-screen.hidden {
  display: none;
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 28px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.login-brand {
  margin-bottom: 4px;
  color: var(--ink);
}

.login-brand span {
  color: var(--muted);
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: var(--text-sm);
  font-weight: 800;
}

.login-hint {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.app-shell.is-locked {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.hidden-control {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 252px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--nav), var(--nav-2));
  color: #f7fbff;
  padding: 24px 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 34px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 800;
}

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

.brand strong {
  font-size: 16px;
  line-height: 1.25;
}

.brand span {
  margin-top: 3px;
  color: #b9c9d7;
  font-size: var(--text-sm);
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 13px 14px;
  background: transparent;
  color: #dce8f1;
  font-size: var(--text-base);
  font-weight: 700;
  text-align: left;
}

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

.icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-weight: 700;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar,
.panel-header,
.modal-header,
.toolbar,
.modal-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.connection {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 700;
}

.connection.ok {
  color: var(--success);
}

.connection.error {
  color: var(--danger);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: var(--text-title);
  line-height: 1.2;
  font-weight: 800;
}

h2 {
  margin-bottom: 16px;
  font-size: var(--text-xl);
  line-height: 1.3;
  font-weight: 800;
}

.toolbar {
  gap: 10px;
  flex-wrap: wrap;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 800;
}

.primary-button,
.ghost-button,
.text-button,
.icon-button,
.danger-button,
.yellow-button {
  border-radius: 8px;
  border: 1px solid transparent;
  min-height: 40px;
  padding: 0 15px;
  font-weight: 700;
}

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

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

.ghost-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.mini-button {
  min-height: 28px;
  padding: 0 10px;
  font-size: var(--text-xs);
}

.record-action-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.state-button {
  border: 1px solid transparent;
  color: #ffffff;
}

.state-button.pending {
  background: var(--success);
}

.state-button.done {
  background: var(--warn);
}

.state-button.attention {
  border-color: #f19a2a;
  animation: approval-pulse 1s ease-in-out infinite;
}

.state-button:disabled {
  cursor: not-allowed;
  opacity: 0.88;
}

.cancel-button {
  background: #fff2f2;
  color: var(--danger);
  border-color: #ffd5d5;
}

.yellow-button {
  background: #ffd75a;
  border: 1px solid #e5b936;
  color: #17202a;
  font-weight: 700;
}

@keyframes approval-pulse {
  0%,
  100% {
    border-color: #f19a2a;
    box-shadow: 0 0 0 0 rgba(241, 154, 42, 0.48);
  }

  50% {
    border-color: #ffbe55;
    box-shadow: 0 0 0 4px rgba(241, 154, 42, 0.12);
  }
}

.text-button {
  min-height: 34px;
  padding: 0;
  background: transparent;
  color: var(--accent-dark);
}

.icon-button {
  width: 40px;
  padding: 0;
  background: var(--soft);
  color: var(--ink);
}

.danger-button {
  min-height: 32px;
  padding: 0 10px;
  background: #fff2f2;
  color: var(--danger);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

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

.metric {
  padding: 20px;
}

.metric span {
  color: var(--muted);
  font-size: var(--text-md);
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 32px;
  line-height: 1.1;
  font-weight: 800;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.work-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.records-layout {
  display: grid;
  grid-template-rows: auto auto;
  gap: 18px;
  min-height: 0;
}

.records-layout > .panel {
  width: 100%;
}

.record-field-grid {
  display: grid;
  grid-template-columns: minmax(210px, 1.25fr) minmax(145px, 0.82fr) minmax(145px, 0.82fr) minmax(105px, 0.58fr) minmax(145px, 0.82fr) minmax(260px, 1.25fr) 120px;
  gap: 12px;
  align-items: end;
}

.record-participants textarea {
  min-height: 40px;
  height: 40px;
  resize: vertical;
}

.record-content-field textarea {
  min-height: 180px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.compact-actions {
  margin-top: 2px;
}

.compact-submit {
  width: 120px;
  min-height: 40px;
}

.pagination {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.record-preview-modal {
  max-width: min(760px, calc(100vw - 32px));
}

.record-preview-body {
  display: grid;
  gap: 10px;
}

.preview-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.preview-row strong,
.preview-row span,
.preview-row div {
  padding: 10px 12px;
}

.preview-row strong {
  background: var(--soft);
}

.preview-row.pre-wrap div {
  white-space: pre-wrap;
}

.records-layout > .panel:last-child {
  align-self: stretch;
}

.course-layout {
  display: grid;
  gap: 18px;
}

.course-form-panel {
  gap: 14px;
}

.course-form-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(170px, 1fr) minmax(170px, 1fr) minmax(110px, 0.6fr) minmax(150px, 0.9fr) minmax(110px, 0.6fr) minmax(145px, 0.75fr) minmax(145px, 0.75fr) 130px;
  gap: 12px;
  align-items: end;
}

.stacked-panels {
  display: grid;
  gap: 18px;
}

.date-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.audit-panel {
  margin-top: 18px;
}

.audit-filter {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 220px)) minmax(110px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.select-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
  align-items: end;
}

.add-master-button {
  min-height: 40px;
  background: var(--accent);
  color: #ffffff;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.add-master-button:hover {
  background: var(--accent-dark);
}

.panel {
  padding: 20px;
  min-width: 0;
}

.panel-header {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header h2 {
  margin-bottom: 0;
}

.record-list-filter {
  display: flex;
  align-items: end;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 7px;
  flex: 1;
}

.record-list-filter label {
  min-width: 108px;
  max-width: 136px;
}

.record-list-filter button {
  flex: 0 0 auto;
}

.record-select-box {
  width: 20px;
  min-height: 20px;
  height: 20px;
  padding: 0;
  margin: 0;
}

.form-panel {
  display: grid;
  gap: 13px;
}

.account-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.account-details summary {
  min-height: 40px;
  padding: 10px 12px;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 800;
  cursor: pointer;
}

.account-details[open] {
  padding-bottom: 12px;
}

.account-details[open] summary {
  margin-bottom: 4px;
}

.account-details label {
  margin: 0 12px 12px;
}

.account-details label:last-child {
  margin-bottom: 0;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

input,
select {
  min-height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 140px;
  padding: 11px;
  resize: vertical;
}

.search-input {
  max-width: 240px;
}

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

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

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: var(--text-md);
}

th {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 800;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: var(--text-xs);
  font-weight: 800;
}

.status.pass {
  background: #e8f7ef;
  color: var(--success);
}

.status.fail {
  background: #fff3e4;
  color: var(--warn);
}

.status.wait {
  background: #eef3f8;
  color: var(--muted);
}

.progress-list,
.question-list,
.test-paper,
.course-grid {
  display: grid;
  gap: 12px;
}

.progress-item {
  display: grid;
  gap: 7px;
}

.progress-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: var(--text-md);
}

.bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf3;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.course-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.course-card,
.question-card,
.notice-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  background: #fbfdff;
}

.course-card h3,
.question-card h3 {
  margin: 0 0 8px;
  font-size: var(--text-lg);
  line-height: 1.35;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: var(--text-sm);
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.notice-list {
  display: grid;
  gap: 12px;
}

.notice-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.notice-head h3 {
  margin: 0 0 5px;
  font-size: var(--text-lg);
  line-height: 1.35;
}

.notice-head p,
.notice-body {
  margin: 0;
  color: var(--muted);
}

.notice-body {
  margin-top: 12px;
  line-height: 1.65;
}

.department-list {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.department-list h3 {
  margin: 0 0 12px;
  font-size: var(--text-lg);
}

.department-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.department-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px 0 12px;
  background: #f8fbfd;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 800;
}

.department-chip button {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: #fff2f2;
  color: var(--danger);
  font-weight: 900;
}

.master-list {
  display: grid;
  gap: 16px;
}

.master-list strong {
  display: block;
  margin-bottom: 8px;
  font-size: var(--text-sm);
}

.muted-text {
  color: var(--muted);
  font-size: var(--text-sm);
}

.role-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

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

dialog {
  width: min(880px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(18, 28, 38, 0.3);
}

dialog::backdrop {
  background: rgba(11, 23, 34, 0.55);
}

.test-modal {
  padding: 22px;
}

.modal-header {
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-header h2 {
  margin-bottom: 0;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.test-question {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.test-question strong {
  display: block;
  margin-bottom: 10px;
  font-size: var(--text-base);
}

.option-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 500;
}

.option-row input {
  width: auto;
  min-height: auto;
}

.modal-actions {
  justify-content: flex-end;
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 14px;
  }

  .brand {
    margin-bottom: 12px;
  }

  .nav-tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-tab {
    justify-content: center;
    padding: 10px 8px;
  }

  .nav-tab span:last-child {
    display: none;
  }

  .main {
    padding: 18px;
  }

  .topbar,
  .split-layout,
  .work-grid,
  .records-layout,
  .record-field-grid,
  .course-form-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .records-layout {
    grid-template-rows: auto auto;
    min-height: 0;
  }

  .topbar {
    display: grid;
  }
}

@media (max-width: 620px) {
  .metric-grid,
  .modal-grid,
  .date-pair,
  .select-with-action {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 25px;
  }

  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .search-input {
    max-width: none;
  }
}
