:root {
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --radius: 16px;
  --shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.05), 0 8px 10px -6px rgba(15, 23, 42, 0.02);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* 브랜드 헤더 */
.brand-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.logo-icon {
  font-size: 24px;
  background: #eff6ff;
  padding: 8px;
  border-radius: 12px;
}
.brand-title {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}

/* 카드 디자인 */
.card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

h1 { font-size: 22px; margin: 0 0 8px; font-weight: 700; }
.card-title { font-size: 18px; margin: 0 0 12px; font-weight: 700; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; line-height: 1.5; }

/* 폼 요소 설정 */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-group { 
  display: flex !important; 
  flex-direction: row !important;
  align-items: center !important; 
  gap: 8px; 
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0 !important;
  width: 110px !important;
  min-width: 110px !important;
  flex-shrink: 0 !important;
  white-space: nowrap;
}

.req { color: var(--danger); }

input[type=text], input[type=date] {
  flex: 1 !important;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: #f8fafc;
  color: var(--text);
  transition: all 0.2s ease;
  outline: none;
}

input[type=text]:focus, input[type=date]:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* 서약 내용 */
.agreement {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  line-height: 1.7;
  max-height: 240px;
  overflow-y: auto;
  background: #f8fafc;
  white-space: pre-line;
  font-size: 14px;
  color: #334155;
}

.check-box {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 18px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.check-box input { width: 18px; height: 18px; accent-color: var(--primary); }

/* 서명 패드 */
.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 250px;
  height: 140px;
  margin: 0 auto 12px;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  transition: border-color 0.2s;
}
.canvas-wrapper:hover { border-color: var(--primary); }

canvas {
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}
.sig-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #94a3b8;
  font-size: 14px;
  pointer-events: none;
}

/* 버튼 스타일 */
.row { display: flex; gap: 10px; }
.button-row { margin-top: 12px; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
  margin-top: 16px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #f1f5f9; color: #334155; }
.btn-secondary:hover { background: #e2e8f0; }

.hidden { display: none !important; }
.adminbar { display: flex; justify-content: space-between; align-items: center; }
.small { font-size: 13px; color: var(--muted); }
.table-responsive { overflow-x: auto; margin-top: 16px; }

/* 관리자 테이블 개선 */
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
th, td { padding: 12px 8px; border-bottom: 1px solid var(--line); text-align: center; vertical-align: middle; } /* 가운데 정렬 적용 */
th { color: var(--muted); font-weight: 600; background: #f8fafc; }

.col-id { width: 48px; text-align: center; white-space: normal; word-break: break-all; }
.col-info { min-width: 90px; text-align: center; }
.col-date { white-space: nowrap; min-width: 95px; text-align: center; }
.col-purpose { min-width: 180px; width: 35%; word-break: break-word; text-align: center; }
.col-sig { min-width: 80px; text-align: center; }

.record-row { cursor: pointer; transition: background 0.15s; }
.record-row:hover { background-color: #f1f5f9; }

/* 모달 (팝업) 스타일 */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-card {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.modal-title { font-size: 18px; font-weight: 700; margin: 0; }
.close-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted);
}
.detail-section { margin-bottom: 16px; }
.detail-label { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.detail-value { font-size: 14px; color: var(--text); background: #f8fafc; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); }

@media (max-width: 520px) {
  .card { padding: 16px; }
  .form-group label {
    width: 95px !important;
    min-width: 95px !important;
  }
}