:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1d2530;
  --muted: #6b7280;
  --line: #d7dce3;
  --brand: #176b87;
  --brand-dark: #0f4e62;
  --danger: #c2410c;
  --ok: #047857;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  padding: 0 14px;
}

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

button.secondary {
  background: #e7ebef;
  color: var(--ink);
}

button.danger {
  background: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: var(--brand);
  text-decoration: none;
}

.shell {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

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

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.topbar nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

.field label {
  font-size: 14px;
  color: var(--muted);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
}

.field textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.55;
}

.hint {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.book-list {
  display: grid;
  gap: 10px;
}

.book-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.folder-card {
  cursor: pointer;
}

.folder-card:hover {
  border-color: var(--brand);
  background: #f8fbfc;
}

.folder-icon {
  display: inline-block;
  width: 18px;
  height: 13px;
  margin-right: 8px;
  border: 2px solid var(--brand);
  border-radius: 3px;
  background: #e8f4f7;
  vertical-align: -1px;
  position: relative;
}

.folder-icon::before {
  content: "";
  position: absolute;
  left: 1px;
  top: -7px;
  width: 8px;
  height: 5px;
  border: 2px solid var(--brand);
  border-bottom: 0;
  border-radius: 3px 3px 0 0;
  background: #e8f4f7;
}

.book-title {
  font-weight: 700;
}

.book-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.sign-book-summary {
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  padding-bottom: 14px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

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

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

.folder-header h2 {
  margin: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: #eef2f5;
  color: var(--ink);
  padding: 0 10px;
  font-size: 13px;
}

.status.done {
  background: #e4f4ec;
  color: var(--ok);
}

.notice {
  border: 1px solid #f0d7af;
  background: #fff7e8;
  border-radius: 8px;
  padding: 12px;
  color: #694514;
}

.result-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.person-option {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.person-label {
  display: block;
  font-size: 24px;
  line-height: 1.25;
}

.person-select-button {
  min-height: 54px;
  font-size: 18px;
  font-weight: 700;
  padding: 0 18px;
}

.signature-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  max-width: 720px;
}

#signatureCanvas {
  width: 100%;
  aspect-ratio: 3 / 1;
  height: auto;
  display: block;
  touch-action: none;
  background: #fff;
}

.complete {
  border-left: 5px solid var(--ok);
}

.qr-box {
  display: grid;
  place-items: center;
  width: 220px;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qr-box canvas,
.qr-box img {
  display: block;
  width: 190px;
  height: 190px;
}

.print-page {
  width: 210mm;
  height: 297mm;
  margin: 0 auto 18px;
  background: white;
  color: #111;
  padding: 8mm 7mm 7mm;
  font-family: "Malgun Gothic", "맑은 고딕", Arial, sans-serif;
  overflow: hidden;
}

.print-title {
  text-align: center;
  font-family: "HY헤드라인M", "Malgun Gothic", "맑은 고딕", Arial, sans-serif;
  font-weight: 900;
  font-size: 23pt;
  line-height: 1.25;
  height: 14mm;
  display: flex;
  align-items: center;
  justify-content: center;
}

.print-topic {
  height: 18mm;
  display: flex;
  align-items: center;
  font-size: 15.5pt;
  font-weight: 800;
  line-height: 1.2;
}

.print-date {
  height: 10mm;
  display: flex;
  align-items: center;
  font-size: 16.5pt;
  font-weight: 800;
  line-height: 1.2;
}

.print-bullet {
  color: #000;
  font-size: 0.78em;
  line-height: 1;
  margin-right: 2mm;
}

.print-spacer {
  height: 6mm;
}

.print-table-wrap {
  width: 100%;
}

.sign-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  border: 2px solid #111;
  font-size: 8.6pt;
}

.sign-table th,
.sign-table td {
  border: 1px solid #111;
  height: 7mm;
  text-align: center;
  vertical-align: middle;
  padding: 0.35mm 0.5mm;
  overflow: hidden;
  line-height: 1.05;
  white-space: normal;
}

.sign-table th {
  height: 7mm;
  font-size: 9.6pt;
  font-weight: 800;
  border-top-width: 2px;
  border-bottom-width: 2px;
}

.sign-table .no {
  width: 6%;
}

.sign-table .position {
  width: 10.4%;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  word-break: keep-all;
  padding-left: 0.2mm;
  padding-right: 0.2mm;
  font-size: 8.2pt;
}

.sign-table .name {
  width: 8.6%;
}

.sign-table .signature {
  width: 8.3%;
}

.sign-table .group-start {
  border-left-width: 2px;
}

.sign-table th:last-child,
.sign-table td:last-child {
  border-right-width: 2px;
}

.sign-table tbody tr:last-child td {
  border-bottom-width: 2px;
}

.signature-img {
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 3 / 1;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.signature-manage-list {
  display: grid;
  gap: 8px;
}

.signature-manage-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1120px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid,
  .book-row,
  .person-option,
  .signature-manage-row,
  .folder-header {
    grid-template-columns: 1fr;
    display: grid;
  }

  button {
    width: 100%;
  }

  .actions button {
    width: auto;
    flex: 1 1 auto;
  }
}

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

@media print {
  body {
    background: #fff;
  }

  .no-print {
    display: none !important;
  }

  .shell {
    width: 100%;
    padding: 0;
  }

  .print-page {
    margin: 0;
    box-shadow: none;
    page-break-after: always;
  }
}
