:root {
  --paper-width: 210mm;
  --paper-height: 297mm;
  --content-left: 17.4mm;
  --content-width: 172.9mm;
  --line: #000;
  --app-bg: #f3f5f7;
  --panel: #fff;
  --border: #d9dee7;
  --text: #141820;
  --muted: #687386;
  --accent: #1f6f57;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--app-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 24px 14px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.app-header h1,
.panel h2,
.card h2 {
  margin: 0;
}

.app-header h1 {
  font-size: 23px;
  line-height: 1.2;
}

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

.header-state {
  min-width: 132px;
  border: 1px solid #cfd6e2;
  border-radius: 999px;
  padding: 7px 12px;
  background: #f9fafb;
  color: #3e4a5c;
  font-size: 13px;
  text-align: center;
}

.tabs,
.subtabs {
  display: flex;
  gap: 6px;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.subtabs {
  padding: 0 0 14px;
  border-bottom: 0;
}

button,
.file-button {
  appearance: none;
  border: 1px solid #bac3d0;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

button:hover,
.file-button:hover {
  background: #f7f9fb;
}

.tab,
.subtab {
  min-width: 142px;
}

.tab.is-active,
.subtab.is-active,
.file-button,
#saveReportButton,
#printButton {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.file-button input {
  display: none;
}

.view {
  display: none;
  padding: 24px;
}

.view.is-active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.summary-item {
  border: 1px solid #dce2eb;
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.summary-item b {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.section-block {
  margin-top: 18px;
}

.student-pane {
  display: none;
}

.student-pane.is-active {
  display: block;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-head h3 {
  margin: 0;
  font-size: 18px;
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 8px;
}

.toolbar label {
  margin-bottom: 0;
  min-width: 150px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

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

.data-table th,
.data-table td {
  border-bottom: 1px solid #e5e9f0;
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #344054;
  font-weight: 700;
}

.data-table.compact select,
.data-table.compact input {
  min-width: 92px;
}

.check-pair {
  display: flex;
  gap: 14px;
  align-items: center;
}

.check-pair label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  white-space: nowrap;
}

.check-pair input {
  width: auto;
  min-width: 0;
}

.data-table select {
  min-width: 128px;
}

.group-roster {
  display: grid;
  gap: 12px;
}

.group-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.group-card-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 12px;
}

.group-card-head label {
  margin-bottom: 0;
}

.mini-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.mini-list span,
.mini-list em {
  border: 1px solid #dce2eb;
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff;
  font-style: normal;
}

.mini-list small {
  color: var(--muted);
}

.empty-text {
  margin: 0;
  color: var(--muted);
}

.attendance-tools,
.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
  margin-bottom: 14px;
}

.report-workspace {
  display: grid;
  grid-template-columns: minmax(340px, 450px) minmax(760px, 1fr);
  gap: 24px;
  align-items: start;
}

.editor {
  max-height: calc(100vh - 142px);
  overflow: auto;
  padding-right: 4px;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 14px;
}

.card h2 {
  margin-bottom: 12px;
  font-size: 16px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: #364152;
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #c7d0dd;
  border-radius: 8px;
  padding: 8px 9px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

.grid {
  display: grid;
  gap: 10px;
}

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

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

.stack {
  display: grid;
  gap: 14px;
}

.group-box {
  border: 1px solid #e1e6ee;
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.group-box h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.save-state {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.danger-button {
  border-color: #cc4a4a;
  color: #a12f2f;
}

.preview-shell {
  overflow: auto;
  padding-bottom: 40px;
}

.paper {
  position: relative;
  width: var(--paper-width);
  height: var(--paper-height);
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.22);
  color: #000;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 10.5pt;
  line-height: 1.45;
  overflow: hidden;
}

.report-title {
  position: absolute;
  left: 0;
  top: 20.4mm;
  width: 210mm;
  text-align: center;
}

.report-title-text {
  display: inline-block;
  font-size: 22pt;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-decoration-line: underline;
  text-underline-offset: 2.1mm;
  text-decoration-thickness: 0.45mm;
}

.report-date {
  margin-top: 3.6mm;
  font-family: "Times New Roman", "Malgun Gothic", serif;
  font-size: 13.5pt;
  line-height: 1;
  letter-spacing: 0.04em;
}

.approval-table {
  position: absolute;
  left: 152.6mm;
  top: 20.3mm;
  width: 38.6mm;
  height: 22.6mm;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 9.6pt;
  line-height: 1.1;
}

.approval-table th,
.approval-table td {
  border: 0.35mm solid var(--line);
  padding: 0;
  text-align: center;
  vertical-align: middle;
  font-weight: 700;
}

.approval-left {
  width: 10.4mm;
  letter-spacing: 0.5mm;
}

.approval-head {
  height: 6.4mm;
}

.approval-sign {
  height: 16.2mm;
}

.reporter-line {
  position: absolute;
  left: 18.1mm;
  top: 37.8mm;
  font-size: 10.4pt;
  line-height: 1.2;
  font-weight: 500;
  text-decoration-line: underline;
  text-underline-offset: 1.4mm;
  text-decoration-thickness: 0.25mm;
}

.section-title {
  position: absolute;
  left: var(--content-left);
  width: var(--content-width);
  font-size: 9.6pt;
  line-height: 1.2;
  font-weight: 800;
}

.status-title { top: 46.7mm; }
.activity-title { top: 107.0mm; }
.attendance-title { top: 149.6mm; }
.long-title { top: 181.9mm; }
.notice-title { top: 225.9mm; }

.report-table {
  position: absolute;
  left: var(--content-left);
  width: var(--content-width);
  border-collapse: collapse;
  table-layout: fixed;
  border: 0.35mm solid var(--line);
  color: #000;
}

.report-table th,
.report-table td {
  border: 0.35mm solid var(--line);
  padding: 0 2.2mm;
  vertical-align: middle;
  white-space: pre-line;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.status-table {
  top: 52.8mm;
  height: 47.9mm;
  font-size: 10.4pt;
}

.status-table tr { height: 15.95mm; }
.status-part-col { width: 20.9mm; }
.status-teacher-col { width: 22.3mm; }
.status-student-col { width: 129.7mm; }
.status-part { text-align: center; font-weight: 500; line-height: 1.45; }
.status-teacher { text-align: center; font-weight: 800; }
.status-students { text-align: left; font-weight: 500; }

.activity-table {
  top: 112.5mm;
  height: 30.2mm;
  font-size: 9.6pt;
  font-weight: 800;
}

.activity-table tr { height: 7.55mm; }
.activity-table td { padding-left: 2.0mm; }

.attendance-table {
  top: 154.9mm;
  height: 20.6mm;
  font-size: 10pt;
}

.attendance-small-col { width: 16.0mm; }
.attendance-small-col.narrow { width: 15.1mm; }
.attendance-reason-col { width: 125.8mm; }

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

.attendance-head-row { height: 10.7mm; }
.attendance-body-row { height: 9.9mm; }
.attendance-table .text-left { text-align: left; padding-left: 2.3mm; }

.long-table {
  top: 187.7mm;
  height: 31.3mm;
  font-size: 9.6pt;
}

.long-table tr { height: 31.3mm; }
.long-left-col { width: 33.9mm; }
.long-body-col { width: 139.0mm; }
.long-left { text-align: center; font-weight: 800; line-height: 1.45; }
.long-body { text-align: left; font-weight: 800; line-height: 1.55; }

.notice-box {
  position: absolute;
  left: var(--content-left);
  top: 230.9mm;
  width: var(--content-width);
  height: 40.6mm;
  border: 0.35mm solid var(--line);
  padding: 8.2mm 2.0mm 2.0mm;
  font-size: 10pt;
  font-weight: 800;
  line-height: 1.65;
  white-space: pre-line;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .report-workspace {
    grid-template-columns: 1fr;
  }

  .editor {
    max-height: none;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }
}

@page {
  size: A4;
  margin: 0;
}

@media print {
  html,
  body {
    width: var(--paper-width);
    height: var(--paper-height);
    background: #fff;
  }

  .no-print,
  .app-header,
  .tabs,
  .view:not(#reportView) {
    display: none !important;
  }

  #reportView,
  main,
  .report-workspace,
  .preview-shell {
    display: block !important;
    padding: 0;
    margin: 0;
    overflow: visible;
  }

  .paper {
    margin: 0;
    box-shadow: none;
    width: var(--paper-width);
    height: var(--paper-height);
    overflow: hidden;
    break-after: avoid;
    page-break-after: avoid;
  }
}
