/* ISO 9001 기록 관리 - 공통 스타일 (청록색 계열, CDN 의존 없음) */

:root {
  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;
  --teal-900: #134e4a;

  --bg: #f6f8f8;
  --surface: #ffffff;
  --text: #1f2a2a;
  --muted: #5b6b6b;
  --border: #dbe3e3;
  --primary: var(--teal-700);
  --primary-hover: var(--teal-800);

  --ok-bg: #dcfce7;   --ok-fg: #166534;
  --warn-bg: #fef3c7; --warn-fg: #92400e;
  --danger-bg: #fee2e2; --danger-fg: #991b1b;

  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 42, 42, 0.06), 0 1px 3px rgba(16, 42, 42, 0.08);
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

/* 머리글 */
.site-header {
  background: var(--teal-800);
  color: #fff;
}
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 12px;
  padding-bottom: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}
.brand:hover { color: #fff; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--teal-100);
  color: var(--teal-900);
  font-size: 12px;
  letter-spacing: 0.02em;
}
.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.main-nav a {
  color: var(--teal-100);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
}
.main-nav a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.main-nav a.active { background: var(--teal-600); color: #fff; }

/* 본문 */
.main { padding-top: 24px; padding-bottom: 40px; }
.page-title { font-size: 22px; margin: 0 0 16px; color: var(--teal-900); }
.section-title { font-size: 17px; margin: 32px 0 12px; color: var(--teal-900); }
.muted { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.mono { font-family: var(--mono); }
.empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* 카드 */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card-label { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0; }
.card-value { font-size: 20px; font-weight: 700; margin: 4px 0 0; }

/* 표: 좁은 화면에서는 가로 스크롤 */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}
.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th {
  background: var(--teal-50);
  color: var(--teal-900);
  font-size: 13px;
  font-weight: 600;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafcfc; }

/* 상태 배지 */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge-danger { background: var(--danger-bg); color: var(--danger-fg); }

/* 버튼 */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--primary-hover); color: #fff; }
.btn-outline { background: var(--surface); color: var(--primary); }
.btn-outline:hover { background: var(--teal-50); color: var(--primary-hover); }

/* 안내·오류 */
.notice {
  max-width: 560px;
  margin: 40px auto;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.debug {
  max-height: 320px;
  overflow: auto;
  padding: 12px;
  background: #1f2a2a;
  color: #e6f0f0;
  border-radius: 6px;
  font-size: 12px;
  white-space: pre-wrap;
}

/* 사용자 메뉴 */
.user-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  font-size: 13px;
  color: var(--teal-100);
}
.user-menu a, .link-button { color: var(--teal-100); }
.user-menu a:hover, .link-button:hover { color: #fff; }
.user-menu form { margin: 0; }
.user-name { color: #fff; font-weight: 600; }
.link-button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* 알림 */
.alert {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
}
.alert-success { background: var(--ok-bg); color: var(--ok-fg); border-color: #bbf7d0; }
.alert-info { background: var(--teal-50); color: var(--teal-900); border-color: var(--teal-100); }
.alert-error { background: var(--danger-bg); color: var(--danger-fg); border-color: #fecaca; }

/* 폼 */
.form { margin: 0; }
.field { margin: 0 0 16px; min-width: 0; }
.field label, .field legend { display: block; margin-bottom: 4px; font-weight: 600; font-size: 14px; }
fieldset.field { border: 0; padding: 0; }
.field input[type="text"], .field input[type="password"], .field input[type="date"],
.field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--teal-600);
  outline-offset: 0;
  border-color: var(--teal-600);
}
.field-help { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.field-error { margin: 4px 0 0; font-size: 13px; color: var(--danger-fg); }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 16px;
}
.field-wide { grid-column: 1 / -1; }
.form-narrow { max-width: 480px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.checkbox { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; cursor: pointer; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--teal-700); }

.auth-box { max-width: 400px; margin: 24px auto; }
.auth-box .form {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-box > .muted { margin-top: 12px; text-align: center; }

.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-danger-outline { background: var(--surface); color: var(--danger-fg); border-color: #fca5a5; }
.btn-danger-outline:hover { background: var(--danger-bg); color: var(--danger-fg); }
.btn:disabled { opacity: 0.6; cursor: default; }

/* 표 보조 */
.table td.center, .table th.center { text-align: center; }
.row-actions { display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; }
.row-actions form { margin: 0; }
.row-disabled td { color: var(--muted); background: #fafafa; }
.badge-muted { background: #e5e7eb; color: #4b5563; }

/* 임시 비밀번호 안내 */
.temp-password {
  margin: 0 0 20px;
  padding: 16px;
  background: var(--warn-bg);
  color: var(--warn-fg);
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
}
.temp-password p { margin: 0 0 6px; }
.temp-password-value {
  display: inline-block;
  padding: 6px 12px;
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  font-size: 20px;
  letter-spacing: 0.08em;
  user-select: all;
}

/* 페이지 머리 */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 16px;
}
.page-head .page-title { margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page-actions form { margin: 0; }
.badge-rev { background: var(--teal-100); color: var(--teal-900); font-family: var(--mono); vertical-align: middle; }

/* JS가 있을 때만 보이는 요소 */
.js-only { display: none; }
.js .js-only { display: inline-flex; }

/* 양식 항목 편집기 */
.field-table { min-width: 560px; }
.field-table td { white-space: normal; vertical-align: middle; }
.field-table input[type="text"], .field-table select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: var(--surface);
}
.field-row.is-deleted input[type="text"] { text-decoration: line-through; color: var(--muted); }
.field-row.is-deleted { background: #fafafa; }
.move-buttons { gap: 2px; }
.icon-button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--teal-800);
  font-size: 10px;
  cursor: pointer;
}
.icon-button:hover { background: var(--teal-50); }
.upper { text-transform: uppercase; }
.card + .card, .form > .card { margin-bottom: 16px; }

/* 개정 이력 */
.revision-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.revision-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.revision-note { margin: 8px 0 4px; }
.change-list { margin: 4px 0 8px; padding-left: 20px; }
.revision details summary { cursor: pointer; color: var(--primary); font-size: 13px; }

/* 기록 목록 */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tab {
  padding: 8px 14px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--teal-800); }
.tab.active { color: var(--teal-800); border-bottom-color: var(--teal-700); font-weight: 600; }
.tab .count {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 2px;
  border-radius: 999px; background: var(--teal-700); color: #fff; font-size: 12px; text-align: center;
}
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.filter-bar select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); font: inherit; max-width: 100%;
}
.pager { display: flex; justify-content: center; gap: 16px; margin-top: 16px; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* 양식 선택 카드 */
.card-link { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--text); }
.card-link:hover { border-color: var(--teal-600); color: var(--text); }
.card-title { font-size: 17px; font-weight: 700; color: var(--teal-900); }

/* 기록 내용 보기 */
.record-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 16px; align-items: start; }
.record-side { display: grid; gap: 16px; }
.record-fields dl { margin: 0; }
.record-fields dt { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 14px; }
.record-fields dt:first-child { margin-top: 0; }
.record-fields dd { margin: 2px 0 0; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.record-fields dd:last-child { border-bottom: 0; padding-bottom: 0; }
.denied { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.transition-form .field { margin-bottom: 10px; }
.timeline { list-style: none; margin: 8px 0 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 12px 16px; border-left: 2px solid var(--teal-100); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--teal-600);
}
.timeline li.event-rejected::before { background: var(--danger-fg); }
.timeline li.event-approved::before { background: var(--ok-fg); }
.event-note { margin-top: 2px; padding: 6px 8px; background: var(--bg); border-radius: 4px; font-size: 13px; white-space: pre-wrap; }

@media (max-width: 800px) {
  .record-layout { grid-template-columns: 1fr; }
}

/* 시스템 화면 */
.system-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 16px;
  align-items: start;
}
.system-actions p { margin: 8px 0; }
.system-actions form { margin: 8px 0 0; }
.verify-result { margin: 12px 0 0; }
.verify-result ul { margin: 8px 0; padding-left: 20px; }

.site-footer {
  padding-bottom: 24px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .page-title { font-size: 19px; }
  .main-nav { width: 100%; }
  .main-nav a { padding: 6px 10px; }
}
