/* TGM 공통 스타일
 *
 * 12장 접근성: 명도 대비 WCAG AA, 색에만 의존하지 않는 상태 표시.
 * 그래서 심각도와 판정에는 색과 함께 기호(●◆▲■○, ✓✕○)를 쓴다.
 */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #d8dde5;
  --border-strong: #b6bfcc;
  --text: #16202e;
  --text-muted: #5b6675;
  --accent: #1c4f8f;
  --accent-weak: #e8eff8;

  --critical: #9b1c1c;
  --high: #b45309;
  --medium: #1c4f8f;
  --low: #4b5563;
  --ok: #166534;

  --radius: 6px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
        "Malgun Gothic", "Noto Sans KR", sans-serif;
}

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5rem; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }

code, .mono { font-family: var(--mono); font-size: .88em; }

.skip-link {
  position: absolute; left: -9999px;
  background: var(--surface); padding: .5rem 1rem; z-index: 100;
}
.skip-link:focus { left: .5rem; top: .5rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ── 레이아웃 ───────────────────────────────────────────────────────────── */

.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: .04em; text-decoration: none; color: var(--text); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.user-chip { color: var(--text-muted); font-size: .9rem; }
.client-picker { padding: .3rem .5rem; border: 1px solid var(--border); border-radius: var(--radius); }

.shell { display: flex; min-height: calc(100vh - 49px); align-items: stretch; }

.sidenav {
  width: 148px; flex: 0 0 148px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: .75rem 0;
  display: flex; flex-direction: column;
}
.sidenav a {
  padding: .45rem 1rem; text-decoration: none; color: var(--text);
  display: flex; align-items: center; gap: .4rem;
}
.sidenav a:hover { background: var(--accent-weak); }
.sidenav a.active { background: var(--accent-weak); border-left: 3px solid var(--accent); font-weight: 600; }

.content { flex: 1; padding: 1.25rem 1.5rem; min-width: 0; }

.centered { display: grid; place-items: center; min-height: 100vh; }

/* ── 패널·표 ────────────────────────────────────────────────────────────── */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
}
.panel.narrow { width: min(380px, 92vw); }
.panel-header { display: flex; align-items: baseline; gap: .75rem; margin-bottom: .75rem; flex-wrap: wrap; }
.panel-header h2 { margin: 0; }
.panel-header .spacer { margin-left: auto; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; color: var(--text-muted); font-size: .85rem; }
tbody tr:hover { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.muted { color: var(--text-muted); }
.small { font-size: .85rem; }

/* ── 신뢰구간 막대 (설계 원칙 4, 9.1) ────────────────────────────────────
 * 점 추정치만 큰 글씨로 보여주는 카드형 KPI는 쓰지 않는다.            */

.ci-bar {
  position: relative; display: inline-block;
  width: 130px; height: 14px; vertical-align: middle;
}
.ci-track {
  position: absolute; top: 6px; left: 0; right: 0; height: 2px;
  background: var(--border-strong);
}
.ci-range {
  position: absolute; top: 3px; height: 8px;
  background: var(--accent-weak); border: 1px solid var(--accent);
  border-radius: 2px;
}
.ci-point {
  position: absolute; top: 1px; width: 2px; height: 12px;
  background: var(--accent);
}
.ci-value { margin-left: .5rem; font-variant-numeric: tabular-nums; }
.ci-value small { color: var(--text-muted); font-weight: 400; }
.metric-empty { color: var(--text-muted); }

.metric-row { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; flex-wrap: wrap; }
.metric-row .engine-name { width: 190px; flex: 0 0 190px; }

.delta { font-variant-numeric: tabular-nums; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--critical); }
.delta .sig { font-weight: 600; }
.delta .not-sig { color: var(--text-muted); font-weight: 400; }

/* ── 상태·심각도 ────────────────────────────────────────────────────────── */

.sev { font-weight: 600; white-space: nowrap; }
.sev-critical { color: var(--critical); }
.sev-high { color: var(--high); }
.sev-medium { color: var(--medium); }
.sev-low, .sev-info { color: var(--low); }

.chip {
  display: inline-block; padding: .1rem .45rem;
  border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: .78rem; color: var(--text-muted); white-space: nowrap;
}
.chip.core { border-color: var(--accent); color: var(--accent); }
.chip.warn { border-color: var(--high); color: var(--high); }
.chip.block { border-color: var(--critical); color: var(--critical); }
.chip.ok { border-color: var(--ok); color: var(--ok); }

.badge {
  margin-left: auto; background: var(--accent); color: #fff;
  border-radius: 999px; padding: 0 .4rem; font-size: .75rem;
}

.bar { display: inline-block; height: 10px; background: var(--accent); vertical-align: middle; }
.bar-track { display: inline-block; width: 120px; background: var(--accent-weak); vertical-align: middle; }

/* ── 알림·고지 ──────────────────────────────────────────────────────────── */

.notice {
  background: var(--accent-weak);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .75rem; margin-bottom: 1rem; font-size: .88rem;
}
.notice summary { cursor: pointer; list-style: none; }
.notice summary::-webkit-details-marker { display: none; }
.notice-more { color: var(--accent); margin-left: .35rem; text-decoration: underline; }
.notice p { margin: .5rem 0 0; color: var(--text-muted); }

.alert {
  background: #fdf2f2; border: 1px solid var(--critical); color: var(--critical);
  border-radius: var(--radius); padding: .5rem .75rem;
}
.alert.warn { background: #fffbeb; border-color: var(--high); color: var(--high); }

/* ── 폼 ─────────────────────────────────────────────────────────────────── */

label { display: block; margin: .75rem 0 .25rem; font-weight: 600; font-size: .88rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=url], input[type=date], select, textarea {
  width: 100%; padding: .45rem .55rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font: inherit; background: var(--surface); color: var(--text);
}
textarea { min-height: 7rem; font-family: var(--mono); font-size: .85rem; }

button, .button {
  font: inherit; padding: .4rem .85rem; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-decoration: none;
  display: inline-block;
}
button:hover, .button:hover { background: var(--accent-weak); }
button.primary, .button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff; margin-top: 1rem;
}
button.primary:hover { background: #163f73; }
button.danger { border-color: var(--critical); color: var(--critical); }
.link-button { border: none; background: none; padding: .2rem .4rem; }
.inline-form { display: inline; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── 행렬 (9.5) ─────────────────────────────────────────────────────────── */

.matrix td.cell { text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
.matrix .spark { display: inline-block; width: 34px; height: 8px; background: var(--accent-weak); margin-left: .3rem; }
.matrix .spark > i { display: block; height: 100%; background: var(--accent); }
.matrix .competitor-note { color: var(--text-muted); font-size: .82rem; }

/* ── 샘플 상세 (9.6) ────────────────────────────────────────────────────── */

.answer { white-space: pre-wrap; line-height: 1.75; }
.mention { padding: 0 .1rem; border-bottom: 2px solid; }
.mention-client { border-color: var(--accent); background: var(--accent-weak); }
.mention-competitor { border-color: var(--high); background: #fff7ed; }
.mention-unknown { border-color: var(--low); background: #f3f4f6; }
.legend { display: flex; gap: 1rem; font-size: .85rem; margin-top: .75rem; flex-wrap: wrap; }

.citation-list { list-style: none; padding: 0; margin: 0; }
.citation-list li { padding: .4rem 0; border-bottom: 1px solid var(--border); }
.citation-list .url { word-break: break-all; font-size: .85rem; }

/* ── 검수함 (9.10) ──────────────────────────────────────────────────────── */

.review-body { white-space: pre-wrap; line-height: 1.8; }
.violation-hit { background: #fff1f2; border-bottom: 2px solid var(--critical); }
.violation-hit.warn { background: #fffbeb; border-color: var(--high); }
.violation-card { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .7rem; margin-bottom: .6rem; }
.violation-card .excerpt { font-family: var(--mono); font-size: .85rem; background: #f9fafb; padding: .2rem .35rem; }

pre.code {
  background: #0f172a; color: #e2e8f0; padding: .75rem;
  border-radius: var(--radius); overflow-x: auto;
  font-family: var(--mono); font-size: .82rem; line-height: 1.5;
}

.empty { color: var(--text-muted); padding: 1.5rem; text-align: center; }

/* 로그인 인증 경로 탭 (3.1) */
.tabs { display: flex; gap: .25rem; margin: 1rem 0 .5rem; border-bottom: 1px solid var(--border); }
.tab {
  padding: .4rem .7rem; text-decoration: none; color: var(--text-muted);
  border: 1px solid transparent; border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0; font-size: .88rem;
}
.tab.active {
  color: var(--text); font-weight: 600;
  background: var(--surface); border-color: var(--border);
  margin-bottom: -1px;
}

/* 좌측 메뉴: 클라이언트가 없어도 자리를 지키는 비활성 항목 */
.nav-disabled {
  padding: .45rem 1rem;
  color: var(--border-strong);
  cursor: not-allowed;
  display: flex; align-items: center; gap: .4rem;
}
.sidenav a[aria-current="page"] { background: var(--accent-weak); }
