/* 비욘드 DART 시스템 — 화면 토큰(2026-10-26 정돈)
   색: paper #fff · ink #151515 · red #e60012(브랜드 마크·기본 동작·'적합' 표시에만) · mist #f4f4f2 · rule #dcdcd8 · muted #6f6f6a
   글꼴: Pretendard Variable 한 가족(base.html 에서 로드). 본문 13px/1.5. 숫자는 tnum(고정폭)·우측 정렬.
   구조: 2px ink 선 = 구역 경계(머리말 아래·표 머리 위), 1px rule = 내부 구분. 모서리 0(브랜드 사각형과 같음).
   간격: 4px 격자. 컨트롤 높이 입력 36px · 보조 버튼 32px · 기본 동작 44px. */
:root {
  --paper: #fff;
  --ink: #151515;
  --red: #e60012;
  --red-ink: #b4000f;
  --mist: #f4f4f2;
  --rule: #dcdcd8;
  --line-ctl: #b9b9b4;
  --muted: #6f6f6a;
  --ok: #0a7a2f;
  --warn: #b00020;
  --ctl: 36px;
  --ctl-sm: 32px;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: var(--fs); line-height: 1.5; font-feature-settings: "tnum"; letter-spacing: -.005em;
}
a { color: inherit; }
h2, h3, h4 { margin: 0; line-height: 1.3; }
p { margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---- 머리말 ---- */
.topbar { display: flex; align-items: center; gap: 24px; height: 56px; padding: 0 32px; border-bottom: 2px solid var(--ink); background: var(--paper); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand .sq { width: 18px; height: 18px; }
.nav { display: flex; align-self: stretch; gap: 2px; }
.nav a { display: flex; align-items: center; padding: 0 10px; text-decoration: none; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--red); }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: var(--fs-sm); white-space: nowrap; }
.who form { margin: 0; }
.who .badge { background: var(--mist); color: var(--muted); }
.page { padding: 24px 32px 56px; }
/* 후보군(.cand)만 전체 폭. 나머지 화면은 읽기 폭으로 제한해 숫자·버튼이 멀리 흩어지지 않게 한다 */
.page > :not(.cand) { max-width: 960px; }
.page > form.panel { max-width: 720px; }

/* ---- 제목·패널 ---- */
.section-title { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 14px; }
.sq { width: 14px; height: 14px; background: var(--red); display: inline-block; flex: none; }
.panel { border: 1px solid var(--rule); background: var(--paper); margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.panel-head strong { font-size: var(--fs-md); }
.panel-head p { flex-basis: 100%; margin: 2px 0 0; color: var(--muted); font-size: var(--fs-sm); }
.panel-body { padding: 16px; }
.panel-body > p:last-child { margin-bottom: 0; }

/* ---- 입력 ---- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); font-weight: 600; margin-bottom: 12px; min-width: 0; }
.field input, .field select, .field textarea {
  width: 100%; min-width: 0; height: var(--ctl); padding: 0 10px; font-size: var(--fs); font-weight: 400;
  border: 1px solid var(--line-ctl); background: var(--paper);
}
.field textarea { height: auto; padding: 8px 10px; line-height: 1.5; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: #a0a09b; }
.field input:focus, .field select:focus, .field textarea:focus,
.tb-field input:focus, .tb-field select:focus, .call-card textarea:focus { outline: 0; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.field small { font-weight: 400; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toggle { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 1px solid var(--rule); padding: 10px 12px; margin-bottom: 12px; cursor: pointer; }
.toggle span { display: flex; flex-direction: column; gap: 1px; }
.toggle strong { font-size: var(--fs); }
.toggle small { color: var(--muted); font-size: var(--fs-sm); }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle i { width: 36px; height: 20px; border-radius: 10px; background: #c9c9c4; position: relative; flex: none; transition: background .15s; }
.toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle input:checked + i { background: var(--red); }
.toggle input:checked + i::after { left: 19px; }
.toggle input:focus-visible + i { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---- 안내·오류 ---- */
.notice { border-left: 3px solid var(--red); background: var(--mist); padding: 10px 12px; font-size: var(--fs-sm); line-height: 1.6; margin: 0 0 14px; }
.notice.ok-box { border-left-color: var(--ok); }
.notice.error { border-left-color: var(--warn); color: var(--warn); }
.error-box { border: 1px solid var(--warn); background: #fff4f4; color: var(--warn); padding: 10px 12px; margin-bottom: 12px; font-size: var(--fs-sm); }

/* ---- 버튼 ---- */
.run { width: 100%; height: 44px; margin-top: 4px; background: var(--ink); color: #fff; border: 0; font-weight: 700; font-size: 15px; cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 8px; }
.run:hover { background: #000; }
.run .run-busy, .run .spin { display: none; }
.run.htmx-request .run-label, .run.busy .run-label { display: none; }
.run.htmx-request .run-busy, .run.busy .run-busy { display: inline-flex; align-items: center; gap: 8px; }
.run.htmx-request .spin, .run.busy .spin { display: inline-block; width: 14px; height: 14px; border: 2px solid #fff; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn { height: var(--ctl-sm); padding: 0 12px; font-size: var(--fs-sm); font-weight: 600; border: 1px solid var(--ink); background: var(--paper); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--mist); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.dark:hover { background: #000; }
.btn:disabled { opacity: .35; cursor: default; }
.btn:disabled:hover { background: var(--paper); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
dialog.guard { border: 1px solid var(--ink); padding: 20px; max-width: 420px; }
dialog.guard::backdrop { background: rgba(0, 0, 0, .35); }
dialog.guard p { margin: 0 0 16px; line-height: 1.6; }
dialog.guard .actions { justify-content: flex-end; }
dialog.guard form { margin: 0; }

/* ---- 후보군: 조건 + 배정 툴바 ---- */
.cand { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 24px; align-items: start; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 0; padding: 10px 16px; }
.tb-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-right: 16px; margin-right: 16px; border-right: 1px solid var(--rule); }
.tb-group:last-child { border-right: 0; margin-right: 0; padding-right: 0; }
.tb-end { margin-left: auto; }
.tb-field { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.tb-field select, .tb-field input { height: var(--ctl-sm); font-size: var(--fs); font-weight: 400; border: 1px solid var(--line-ctl); background: var(--paper); padding: 0 8px; }
.tb-field select { min-width: 200px; }
.tb-field input { width: 64px; text-align: right; }

/* ---- 결과 표 ---- */
.table-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
.count { color: var(--muted); font-weight: 500; }
.count b { color: var(--ink); font-size: var(--fs-xl); font-weight: 700; margin: 0 2px; letter-spacing: -.01em; }
.pager { display: flex; gap: 8px; align-items: center; font-size: var(--fs-sm); }
.pager span { min-width: 64px; text-align: center; }
.table-wrap { overflow-x: auto; }
table.results { width: 100%; border-collapse: collapse; font-size: var(--fs); }
.results th { background: var(--mist); text-align: left; padding: 9px 10px; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule); white-space: nowrap; font-size: var(--fs-sm); font-weight: 600; }
.results td { padding: 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.results tbody tr:hover > td { background: #fafaf8; }
.results td small { color: var(--muted); font-size: var(--fs-sm); }
.results td strong { font-weight: 600; }
.results .num { text-align: right; white-space: nowrap; }
.results .num b { font-weight: 700; }
.results a { color: var(--ink); font-weight: 600; }
.results td small a { font-weight: 500; }
.results .x { width: 32px; padding-right: 2px; }
.results tr.fail > td { color: var(--muted); }
.expand { width: 24px; height: 24px; border: 0; background: none; cursor: pointer; font-size: 12px; color: var(--muted); }
.expand[aria-expanded="true"] { color: var(--ink); }
.badge { display: inline-block; padding: 0 8px; line-height: 20px; font-size: var(--fs-xs); font-weight: 700; background: var(--mist); color: var(--ink); white-space: nowrap; }
.badge.ok { background: var(--red); color: #fff; }
.badge.no { background: var(--mist); color: var(--muted); }
.badge.warn { background: var(--paper); border: 1px solid var(--red); color: var(--red); line-height: 18px; }
.reason { font-size: var(--fs-xs); }
.empty { text-align: center; color: var(--muted); padding: 32px !important; }
.detail-row > td { background: var(--mist) !important; padding: 16px 20px 18px; }
.detail { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.detail h4 { font-size: var(--fs); font-weight: 700; margin: 0 0 8px; padding-bottom: 6px; border-bottom: 1px solid #cfcfca; }
.detail h4 small { font-weight: 400; }
.detail p { font-size: var(--fs-sm); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 8px; font-size: var(--fs-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
table.mini { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); margin-top: 6px; }
.mini th, .mini td { border-bottom: 1px solid #cfcfca; padding: 4px 6px; text-align: left; vertical-align: top; }
.mini th.num, .mini td.num { text-align: right; white-space: nowrap; }
.quote { max-width: 240px; }
ul.quotes { margin: 4px 0 8px; padding-left: 18px; font-size: var(--fs-sm); }

/* ---- 공용 글자 ---- */
.help { font-size: var(--fs-sm); color: var(--muted); margin: 12px 0 0; }
.help a { color: var(--ink); }
.muted { color: var(--muted); }
.warn { color: var(--warn); font-weight: 700; }
.src-parser { font-style: italic; }
.saved { color: var(--ok); display: block; }
.plain { font-weight: 400; }

/* ---- 로그인 ---- */
.page > .auth-card { max-width: 400px; margin: 56px auto 0; }   /* 위 읽기 폭 규칙(.page > :not(.cand))보다 뒤에 두어 400px 이 이긴다 */
.auth-card .panel-head strong { font-size: var(--fs-lg); }
.auth-card .field:last-of-type { margin-bottom: 16px; }

/* ---- 통화 카드·기록 ---- */
.call-card .panel-head strong { font-size: var(--fs-lg); margin-right: 4px; }
.call-card .panel-body p { margin: 0 0 6px; }
.call-card .panel-body form { margin-top: 12px; }
.call-card textarea { width: 100%; border: 1px solid var(--line-ctl); padding: 8px 10px; line-height: 1.5; resize: vertical; }
.call-card .actions { margin-top: 2px; }
table.history { width: 100%; border-collapse: collapse; }
table.history th { background: var(--mist); font-size: var(--fs-sm); font-weight: 600; text-align: left; padding: 9px 12px; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule); }
table.history td { border-bottom: 1px solid var(--rule); padding: 9px 12px; text-align: left; vertical-align: top; }

/* ---- 관심 기업 타임라인 ---- */
ol.timeline { list-style: none; margin: 16px 0 0; padding: 0; }
ol.timeline li { border-left: 2px solid var(--rule); padding: 2px 0 2px 14px; margin-bottom: 14px; }
ol.timeline li.tl-call { border-left-color: var(--red); }
.tl-text { white-space: pre-wrap; margin: 4px 0 0; }

/* ---- 반응형 ---- */
@media (max-width: 1200px) { .detail { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
  .nav { order: 3; flex-basis: 100%; }
  .nav a { padding: 6px 8px 8px; }
  .page { padding: 16px; }
  .cand { grid-template-columns: 1fr; }
  .detail { grid-template-columns: 1fr; }
  .tb-group { border-right: 0; margin-right: 0; padding-right: 0; }
  .tb-end { margin-left: 0; }
}
