/* SHE 사고관리 이행 점검 — 업무용 차분한 화면. 흰 바탕·짙은 회색 글자·파랑 강조 1색, 상태는 색 + 글자 배지. */
:root {
  --bg: #ffffff;
  --surface: #f6f7f9;
  --line: #d5dae1;
  --text: #1f2933;
  --muted: #52606d;
  --accent: #1d4ed8;
  --accent-dark: #1e3a8a;
  --accent-soft: #e8eefc;
  --focus: #1d4ed8;
  --danger: #b42318;
  --s-done-bg: #e6f4ea; --s-done: #1e6b34;
  --s-late-bg: #fdf0e1; --s-late: #8a4b00;
  --s-over-bg: #fde8e8; --s-over: #b42318;
  --s-check-bg: #f1ebfb; --s-check: #5b2d9e;
  --s-wait-bg: #eef0f3; --s-wait: #3e4c59;
  --s-na-bg: #f5f6f8; --s-na: #616e7c;
  --radius: 8px;
  --tabs-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --t: 200ms;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font);
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  word-break: keep-all; overflow-wrap: anywhere; /* 한글은 어절 단위로 줄바꿈 */
}
body.no-tabs { padding-bottom: 0; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 8px; }
h1 { font-size: 1.375rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 8px; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 8px; top: 8px; background: var(--bg); padding: 8px 12px; z-index: 50; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .875rem; word-break: break-all; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.nw { white-space: nowrap; } /* 날짜·시각·남은 시간 묶음 */
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.loading { color: var(--muted); padding: 24px 0; }

/* 머리 */
.top { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1200px; margin: 0 auto; padding: 8px 16px; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; white-space: nowrap; flex: none; }
.brand-short { display: none; }
.top-user { display: flex; gap: 4px; align-items: center; flex-wrap: nowrap; justify-content: flex-end; min-width: 0; }
.who { font-size: .875rem; color: var(--muted); margin-right: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@media (max-width: 599px) {
  .brand-long { display: none; }
  .brand-short { display: inline; }
}

main { display: block; max-width: 1200px; margin: 0 auto; padding: 16px; outline: none; }

/* 하단 탭 */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--bg); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  min-height: var(--tabs-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .8125rem;
}
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }
.ico { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* 버튼·입력 */
.btn {
  min-height: 44px; padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; text-decoration: none; color: var(--text);
  transition: background-color var(--t), border-color var(--t);
}
.btn:hover { background: var(--surface); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.outline { color: var(--accent); border-color: var(--accent); background: var(--bg); }
.btn.small { min-height: 44px; padding: 6px 12px; font-size: .875rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { min-width: 44px; min-height: 44px; border: 0; background: none; border-radius: var(--radius); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--text); }
.icon-btn:hover { background: var(--surface); }
label.field { display: block; }
.field > span { display: block; font-weight: 600; margin-bottom: 4px; }
.field > small { display: block; color: var(--muted); margin-top: 4px; }
input[type="text"], input[type="password"], input[type="url"], input[type="number"], input[type="datetime-local"], input[type="date"],
select, textarea {
  width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid #8a96a3; border-radius: var(--radius); background: var(--bg);
}
textarea { min-height: 96px; resize: vertical; }
input[type="file"] { min-height: 44px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; }
legend { font-weight: 600; padding: 0 4px; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid #8a96a3; border-radius: var(--radius); overflow: hidden; }
.seg label { position: relative; min-height: 44px; min-width: 64px; display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; cursor: pointer; border-left: 1px solid var(--line); }
.seg label:first-child { border-left: 0; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg label:has(input:checked) { background: var(--accent); color: #fff; font-weight: 600; }
.seg label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; }
.q { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.q > span { flex: 1 1 180px; }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

/* 배지 */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .8125rem; font-weight: 600;
  border: 1px solid currentColor; white-space: nowrap; line-height: 1.5;
}
.badge.wrap { white-space: normal; } /* 사유 문구가 붙는 배지(CAPA 회차 판정 보류) */
.st-done { background: var(--s-done-bg); color: var(--s-done); }
.st-late { background: var(--s-late-bg); color: var(--s-late); }
.st-over { background: var(--s-over-bg); color: var(--s-over); }
.st-check { background: var(--s-check-bg); color: var(--s-check); }
.st-wait { background: var(--s-wait-bg); color: var(--s-wait); }
.st-na { background: var(--s-na-bg); color: var(--s-na); }
.b-grade { background: var(--accent-soft); color: var(--accent-dark); }
/* 등급 배지 — 글자 대비 4.5:1 이상(A 6.6 · B 6.4 · C 7.8 · D 8.3) */
.b-grade.g-A { background: #b42318; color: #fff; border-color: #b42318; }
.b-grade.g-B { background: #ffedd5; color: #9a3412; }
.b-grade.g-C { background: #fef3c7; color: #713f12; }
.b-grade.g-D { background: #e5e7eb; color: #374151; }
.b-info { background: #fff7e0; color: #7a5200; }
.b-tag { background: #eef0f3; color: #52606d; font-weight: 500; border-style: dashed; }
.b-void { background: #f5f6f8; color: #3e4c59; }

/* 요약·카드 */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.sum { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--surface); }
.sum > span { display: block; }
.sum b { display: block; font-size: 1.5rem; color: var(--text); }
.sum.over b { color: var(--s-over); }
.sum.soon b { color: var(--s-late); }
.sum-sub { font-size: .75rem; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { min-height: 44px; padding: 6px 14px; border-radius: 999px; border: 1px solid #8a96a3; background: var(--bg); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip .ico { width: 18px; height: 18px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chip-n { min-width: 1.5em; padding: 0 6px; border-radius: 999px; background: var(--surface); color: var(--text); font-size: .8125rem; font-weight: 600; text-align: center; }
.chip[aria-pressed="true"] .chip-n { background: #fff; color: var(--accent-dark); }
.cards { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); } /* 말줄임(nowrap)이 열을 넓히지 않게 */
.card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: var(--bg); display: block; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--accent); }
.card h3 { margin: 4px 0; }
.card-top { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.card-top .meta { flex: 1 1 auto; min-width: 0; }
.rt { white-space: nowrap; font-size: .9375rem; color: var(--text); }
.rt.over { color: var(--s-over); }
.rt.soon { color: var(--s-late); }
.urgent-line { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.urgent-line .clip { flex: 1 1 auto; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .875rem; color: var(--muted); }
progress { width: 100%; height: 8px; accent-color: var(--accent); }
.empty { color: var(--muted); padding: 24px 0; }

/* 등록 단계 */
.steps { display: flex; gap: 8px; margin-bottom: 16px; padding: 0; list-style: none; }
.steps li { flex: 1; border-top: 4px solid var(--line); padding-top: 4px; font-size: .875rem; color: var(--muted); }
.steps li[aria-current="step"] { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.steps li.done { border-color: var(--accent-dark); }
.helper { display: grid; gap: 4px; }
.preview { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius); padding: 12px; }
.preview b { font-size: 1.25rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* 사고 상세 */
.head { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 12px; }
.head dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 8px 0 0; font-size: .9375rem; }
.head dt { color: var(--muted); }
.head dd { margin: 0; min-width: 0; }
.urgent-dd summary { display: flex; gap: 8px; align-items: center; cursor: pointer; min-height: 32px; }
.urgent-dd summary .clip { flex: 1 1 auto; }
.urgent-dd p { margin: 4px 0 0; }
details.more { position: relative; }
details.more > summary { list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
.more-body { margin-top: 8px; }
.bl-code { color: var(--muted); font-size: .75rem; }
.voided { border: 1px solid var(--line); background: var(--surface); padding: 12px; border-radius: var(--radius); margin-bottom: 12px; }
.tablist { display: flex; border-bottom: 1px solid var(--line); margin: 12px 0; overflow-x: auto; }
.tablist button { min-height: 44px; padding: 8px 16px; border: 0; background: none; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; }
.tablist button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
details.stage { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
details.stage > summary { min-height: 44px; padding: 10px 12px; cursor: pointer; font-weight: 700; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.items { list-style: none; margin: 0; padding: 0 12px 8px; }
.item { border-top: 1px solid var(--line); padding: 10px 0; }
.item-top { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.item-title { flex: 1 1 220px; font-weight: 600; }
.item-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .875rem; color: var(--muted); margin: 4px 0; }
.item-reason { font-size: .875rem; color: var(--s-check); margin: 4px 0; }
.item-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.cite { border-left: 4px solid var(--accent); background: var(--surface); padding: 10px 12px; margin-top: 8px; border-radius: 0 var(--radius) var(--radius) 0; font-size: .9375rem; }
.cite blockquote { margin: 6px 0; }
.ev-list { list-style: none; margin: 6px 0 0; padding: 0; font-size: .875rem; }
.ev-list li { padding: 6px 0; border-top: 1px dashed var(--line); }
.ev-void { text-decoration: line-through; color: var(--muted); }
.hint { font-size: .875rem; color: var(--muted); background: var(--surface); border-radius: var(--radius); padding: 6px 10px; }
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: grid; grid-template-columns: 1fr; gap: 2px; padding: 10px 0 10px 16px; border-left: 3px solid var(--line); position: relative; }
.tl li.ev { border-left-color: var(--accent); }
.tl .tl-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: .875rem; color: var(--muted); }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { padding: 8px 0; border-top: 1px solid var(--line); font-size: .9375rem; }

/* CAPA 보드 */
.board { display: grid; gap: 12px; grid-template-columns: 1fr; }
.col { background: var(--surface); border-radius: var(--radius); padding: 10px; }
.col > h2 { font-size: 1rem; display: flex; justify-content: space-between; }
.col .card + .card { margin-top: 8px; }

/* 연간 */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
table.plain { border-collapse: collapse; width: 100%; font-size: .9375rem; }
table.plain th, table.plain td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; }

/* 알림(하단 고정 — 탭 위, 시트 안에서는 시트 상단 .sheet-alert 를 쓴다) */
.alert {
  position: fixed; left: 8px; right: 8px; bottom: calc(var(--tabs-h) + 8px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 720px; margin: 0 auto; display: flex; gap: 8px; align-items: center; justify-content: space-between;
  padding: 6px 6px 6px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg); box-shadow: 0 4px 16px rgba(15, 23, 42, .15);
}
body.no-tabs .alert { bottom: 8px; }
.alert.error { border-color: var(--s-over); background: var(--s-over-bg); color: var(--s-over); }
.alert.info { border-color: var(--s-done); background: var(--s-done-bg); color: var(--s-done); }
.alert p { margin: 0; }
body.has-alert main { padding-bottom: 96px; }
.sheet-alert { border: 1px solid var(--s-over); background: var(--s-over-bg); color: var(--s-over); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 12px; }
.sheet-alert.info { border-color: var(--s-done); background: var(--s-done-bg); color: var(--s-done); }

/* 시트(dialog) */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 640px; max-height: 88vh; border-radius: 12px 12px 0 0;
  background: var(--bg); color: var(--text); box-shadow: 0 -8px 30px rgba(15, 23, 42, .2);
}
dialog.sheet::backdrop { background: rgba(15, 23, 42, .45); }
dialog.sheet[open] { display: flex; flex-direction: column; animation: up var(--t) ease-out; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; }
.sheet-body { padding: 16px; overflow-y: auto; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.secret-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; background: var(--surface); }
.blockers { margin: 0; padding-left: 20px; }
.blockers li { margin: 4px 0; }
.forbidden { border: 1px solid var(--s-over); background: var(--s-over-bg); color: var(--s-over); border-radius: var(--radius); padding: 16px; }
.auth { max-width: 420px; margin: 24px auto; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; }

@media (min-width: 768px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  dialog.sheet { margin: auto; border-radius: 12px; }
}
@media (min-width: 1024px) {
  main { padding: 24px; }
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .board { grid-template-columns: repeat(4, 1fr); align-items: start; }
  /* 넓은 화면: 하단 탭 대신 머리 안 가로 탭(본문을 가리지 않게) */
  body { padding-bottom: 0; }
  .alert { bottom: 8px; }
  .tabs { position: static; display: flex; flex: 1 1 auto; justify-content: center; gap: 4px; border: 0; padding: 0; background: none; }
  .tabs a { min-height: 44px; flex-direction: row; gap: 6px; padding: 0 14px; font-size: .9375rem; border-radius: var(--radius); }
  .tabs a:hover { background: var(--surface); }
  .tabs a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--accent); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
