/* INSPIRE eCRF — 케이스북 레이아웃(사이드바 + 방문×모듈 매트릭스), 폼 툴바, 필드 도구, 로그인. app.css 뒤에 로드된다. */

/* 상단 내비 보강 */
.topnav { gap: 1rem; }
.topnav .brand { display: inline-flex; align-items: center; gap: .5rem; }
.brand-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; background: #2563eb; color: #fff; font-size: .72rem; font-weight: 800; letter-spacing: .02em; }
.brand-sub { color: #94a3b8; font-weight: 400; font-size: .8rem; margin-left: .2rem; }
.nav-search input { width: 200px; padding: .3rem .6rem; border-radius: 6px; border: 1px solid #334155; background: #1e293b; color: #e2e8f0; font: inherit; font-size: .85rem; }
.nav-search input::placeholder { color: #64748b; }
.nav-search input:focus { outline: 2px solid #3b82f6; border-color: #3b82f6; }
.userbox .btn-primary { border-color: #2563eb; }
.container.wide { max-width: 1480px; }

/* 상태 점 */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: .35rem; border: 2px solid #cbd5e1; background: #fff; box-sizing: border-box; }
.dot.st-none { background: #fff; border-color: #cbd5e1; }
.dot.st-draft { background: #f59e0b; border-color: #f59e0b; }
.dot.st-submitted { background: #2563eb; border-color: #2563eb; }
.dot.st-verified { background: #16a34a; border-color: #16a34a; }
.dot.st-locked { background: #1f2937; border-color: #1f2937; }
.badge .dot { width: 8px; height: 8px; margin-right: .3rem; }
.legend-inline, .sb-legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .78rem; color: var(--muted); }
.tag { display: inline-block; font-size: .7rem; padding: .05rem .4rem; border-radius: 4px; background: #f1f5f9; color: #475569; margin-left: .3rem; vertical-align: middle; }
.tag-int { background: var(--intervention); color: #78350f; }
.mcode { font-family: Consolas, "D2Coding", monospace; font-weight: 700; color: #1e3a8a; font-size: .92em; }

/* 작업 화면: 사이드바 + 본문 */
.workspace { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 1.1rem; align-items: start; }
.sidebar { position: sticky; top: .8rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; max-height: calc(100vh - 1.6rem); display: flex; flex-direction: column; }
.workmain { min-width: 0; }
.sb-subject { padding: .9rem 1rem .8rem; border-bottom: 1px solid var(--line); background: #f8fafc; }
.sb-id { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: 1.15rem; font-weight: 700; margin-bottom: .35rem; }
.sb-meta { margin: 0; display: grid; gap: .15rem; font-size: .82rem; }
.sb-meta div { display: flex; gap: .5rem; }
.sb-meta dt { color: var(--muted); min-width: 64px; }
.sb-meta dd { margin: 0; }
.sb-subject .progress { margin: .55rem 0 .25rem; }
.sb-nav { overflow-y: auto; padding: .4rem 0; flex: 1; }
.sb-item { display: flex; align-items: center; gap: .45rem; padding: .38rem .9rem; color: var(--text); font-size: .86rem; border-left: 3px solid transparent; }
.sb-item:hover { background: #f1f5f9; text-decoration: none; }
.sb-item.active { background: #eff6ff; border-left-color: var(--primary); font-weight: 600; }
.sb-item .dot { flex: none; margin: 0; }
.sb-code { font-family: Consolas, "D2Coding", monospace; font-size: .76rem; color: #475569; flex: none; width: 50px; }
.sb-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-home { border-bottom: 1px dashed var(--line); margin-bottom: .3rem; padding-bottom: .5rem; }
.sb-ico { width: 10px; text-align: center; color: #64748b; flex: none; }
.sb-tags { display: flex; gap: .25rem; flex: none; }
.sb-cnt, .sb-q, .sb-ai { font-size: .68rem; padding: 0 .35rem; border-radius: 999px; background: #e5e7eb; color: #374151; font-weight: 600; }
.sb-q { background: #fee2e2; color: var(--danger); }
.sb-ai { background: #fef3c7; color: var(--warn); }
.sb-legend { padding: .5rem 1rem; border-top: 1px solid var(--line); }
.sb-actions { display: flex; flex-wrap: wrap; gap: .35rem; padding: .6rem 1rem .8rem; border-top: 1px solid var(--line); background: #f8fafc; }

/* 케이스북 매트릭스 */
table.casebook { table-layout: fixed; }
.casebook th, .casebook td { border: 1px solid var(--line); vertical-align: middle; }
.casebook thead th { text-align: center; background: #f1f5f9; }
.casebook thead th.cb-mod { text-align: left; width: 30%; }
.casebook thead th.cb-q { width: 64px; }
.casebook .cb-visit .v-id { display: block; font-weight: 700; }
.casebook .cb-visit .hint { white-space: normal; font-weight: 400; }
.casebook tbody th.cb-mod { background: #fafafa; font-weight: 500; text-align: left; }
.casebook tbody th.cb-mod a { color: var(--text); }
.casebook tbody th.cb-mod a:hover { color: var(--primary); }
.casebook td.na { background: repeating-linear-gradient(135deg, #f8fafc 0 6px, #f1f5f9 6px 12px); }
.casebook td.cb-cell { text-align: center; padding: .4rem .5rem; }
.casebook td.cb-q { text-align: center; }
.casebook tr.subrow th { padding-left: 1.4rem; font-size: .86rem; color: #475569; background: #fff; }
.sub-mark { color: #94a3b8; margin-right: .2rem; }
.chip { display: inline-flex; align-items: center; gap: .1rem; margin: .12rem; padding: .16rem .5rem; border-radius: 6px; border: 1px solid #cbd5e1; background: #fff; font-size: .8rem; font-weight: 600; color: var(--text); line-height: 1.25; }
.chip:hover { text-decoration: none; border-color: var(--primary); color: var(--primary); }
.chip.st-none { color: #94a3b8; border-style: dashed; font-weight: 500; }
.chip.st-draft { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.chip.st-submitted { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }
.chip.st-verified { background: #f0fdf4; border-color: #86efac; color: #166534; }
.chip.st-locked { background: #1f2937; border-color: #1f2937; color: #fff; }
.chip.wide { padding: .3rem .9rem; }
.chip.add { border-style: dashed; color: var(--primary); background: #fff; }
.chip.add:hover { background: #eff6ff; }
.chip .dot { margin-right: .35rem; }
.chip.st-locked .dot { border-color: #fff; background: #fff; }

/* 폼 툴바와 본문 */
.form-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.form-toolbar h1 { margin: 0 0 .3rem; font-size: 1.3rem; }
.ft-badges { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.ft-right { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.desc-box { margin: 0 0 .8rem; font-size: .88rem; color: var(--muted); }
.desc-box summary { cursor: pointer; color: var(--primary); }
.desc-box .desc { margin: .3rem 0 0; }
.form-body { display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 1rem; align-items: start; }
.form-body form.crf { min-width: 0; }
.form-side { position: sticky; top: .8rem; display: flex; flex-direction: column; gap: .7rem; }
.side-box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .85rem; font-size: .85rem; }
.side-title { font-weight: 700; margin-bottom: .4rem; color: #334155; }
.sec-nav { margin: 0; padding-left: 1.2rem; display: grid; gap: .25rem; }
.sec-nav a { color: var(--text); }
.sec-nav li.active > a { color: var(--primary); font-weight: 600; }
.side-box.transitions form { margin-bottom: .45rem; }
.side-box.transitions input { width: 100%; margin-bottom: .3rem; }
.legend-box { display: flex; gap: .8rem; color: var(--muted); }
fieldset.card.sec legend { display: flex; align-items: center; gap: .45rem; }
.sec-no { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #1e293b; color: #fff; font-size: .75rem; }
.field { grid-template-columns: 320px 1fr; }
.field:hover { background: #fafbfc; }
.field.has-query .flabel-text { text-decoration: underline dotted var(--danger); text-underline-offset: 3px; }
.req-counter { font-size: .85rem; color: var(--muted); padding: .2rem .6rem; border: 1px solid var(--line); border-radius: 999px; background: #f8fafc; }
.req-counter b { color: var(--danger); }
.req-counter.done { background: #f0fdf4; border-color: #bbf7d0; }
.req-counter.done b { color: var(--ok); }
.visit-row label { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; margin-right: .8rem; }
.new-record-row { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; padding: .6rem 1rem; }
.new-record-row .k { color: var(--muted); font-size: .85rem; margin-right: .3rem; }

/* 필드 도구 (이력, Query) */
.ftools { display: inline-flex; gap: .2rem; margin-left: .4rem; vertical-align: middle; opacity: .55; }
.field:hover .ftools, .field:focus-within .ftools { opacity: 1; }
.ftool { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 .3rem; border-radius: 4px; border: 1px solid #cbd5e1; background: #fff; color: #475569; font: inherit; font-size: .72rem; cursor: pointer; line-height: 1; }
.ftool:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.ftool.qflag { background: #fee2e2; border-color: #fca5a5; color: var(--danger); font-weight: 700; opacity: 1; }
.ftool-details { display: inline-block; position: relative; }
.ftool-details summary { list-style: none; }
.ftool-details summary::-webkit-details-marker { display: none; }
.ftool-details[open] .qform { position: absolute; z-index: 5; top: 24px; left: 0; display: flex; gap: .3rem; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: .4rem; box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.qform input { width: 240px; }
.fhist-slot:empty { display: none; }
.fhist { margin-top: .4rem; border: 1px solid var(--line); border-radius: 6px; background: #f8fafc; padding: .5rem .6rem; font-size: .82rem; }
.fhist-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .3rem; }
.fhist-head .btn { margin-left: auto; }

/* 대상자 목록 진행률 */
.w-prog { width: 130px; }
.mini-prog { height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; margin-bottom: .15rem; }
.mini-prog .bar { height: 100%; background: var(--ok); }

/* 로그인 */
.login-wrap { display: grid; grid-template-columns: 1.1fr .9fr; gap: 2rem; max-width: 920px; margin: 3rem auto; align-items: center; }
.login-brand h1 { font-size: 2rem; margin: .6rem 0 .4rem; }
.login-brand p { color: var(--muted); margin: 0 0 1rem; }
.login-mark { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: #0f172a; color: #60a5fa; font-weight: 800; font-size: 1.1rem; }
.login-points { margin: 0; padding-left: 1.1rem; color: #475569; font-size: .88rem; display: grid; gap: .3rem; }
.login-card { padding: 1.4rem 1.6rem; margin: 0; }
.login-card h2 { margin-bottom: .8rem; }
.login-card .btn-primary { padding: .6rem; font-weight: 600; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .sb-nav { max-height: 260px; }
  .form-body { grid-template-columns: 1fr; }
  .form-side { position: static; }
  .nav-search { display: none; }
}
@media (max-width: 760px) {
  .login-wrap { grid-template-columns: 1fr; margin: 1rem auto; }
}
@media print {
  .sidebar, .form-side, .ftools, .form-toolbar .ft-right, .actions.sticky { display: none !important; }
  .workspace, .form-body { display: block; }
}
