/* 기본 화면 (디자인 시안은 디자인봇이 따로 만든다). 폰 세로 기준, 가로 100%. */
/* 시안 8 "사건 달력": 흰 바탕·짙은 먹색 글자·알약 탭·사건 수 붉은 색 단계 */
:root {
  --bg: #ffffff; --surface: #ffffff; --band: #f3f4f7; --line: #eceef2; --line-soft: #f2f3f6; --text: #141821; --muted: #6a7180; --faint: #9aa0ab;
  --accent: #141821; --accent-ink: #ffffff; --link: #c4372c; --chip: #f1f3f6; --chip-ink: #555c69; --chip2: #f1f3f6; --chip2-ink: #555c69;
  --h0: #f3f4f7; --h1: #ffe3d6; --h2: #ffb59a; --h3: #ff7a5a; --h4: #d9342b; --h-ink: #141821; --h-ink-strong: #ffffff; --h3-ink: #141821; --out: #c5cad3;
  --sev1: #6a7180; --sev2: #8a6a5e; --sev3: #b85a35; --sev4: #d4472a; --sev5: #c4222b;
  --bar1: #d5d9e0; --bar2: #ffd0bd; --bar3: #ffb59a; --bar4: #ff7a5a; --bar5: #d9342b;
  --chart: #ff7a5a;
  --gutter: clamp(16px, 4.6vw, 24px);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318; --surface: #111318; --band: #1d2027; --line: #2a2e36; --line-soft: #22252c; --text: #eceef2; --muted: #a3a9b4; --faint: #7d838e;
    --accent: #eceef2; --accent-ink: #111318; --link: #ff8a6e; --chip: #23262e; --chip-ink: #c3c8d1; --chip2: #23262e; --chip2-ink: #c3c8d1;
    --h0: #1d2027; --h1: #3a2420; --h2: #5e2c22; --h3: #9c3a26; --h4: #d9342b; --h-ink: #eceef2; --h-ink-strong: #ffffff; --h3-ink: #ffffff; --out: #4a4f59;
    --sev1: #a3a9b4; --sev2: #d8a593; --sev3: #f0956f; --sev4: #ff7a5a; --sev5: #ff5d5d;
    --bar1: #4a4f59; --bar2: #6b3a2d; --bar3: #b0583b; --bar4: #ff7a5a; --bar5: #ff4b3e;
    --chart: #ff7a5a;
  }
}
* { box-sizing: border-box; }
html, body { overflow-x: clip; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); -webkit-text-size-adjust: 100%; word-break: keep-all; overflow-wrap: anywhere; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; top: 8px; left: 8px; z-index: 50; background: var(--surface); padding: 8px 12px; }
.muted { color: var(--muted); }

/* 머리글: 고정 */
.appbar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.bar { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 4px var(--gutter) 0; }
.brand { display: flex; align-items: center; min-height: 44px; font-weight: 800; font-size: 18px; letter-spacing: -.01em; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.brand:hover { text-decoration: none; }
/* 영어 이름이 더 길어 좁은 폰(320~360px)에서 메뉴와 붙거나 잘리지 않게 조금 줄인다 */
html[lang="en"] .brand { font-size: clamp(15px, 4.6vw, 18px); }
.actions { display: flex; align-items: center; flex: none; margin-right: -9px; }
.txt-btn { position: relative; display: inline-flex; align-items: center; min-height: 44px; padding: 0 9px; font: 500 13px/1 var(--font); color: var(--muted); background: none; border: 0; cursor: pointer; white-space: nowrap; }
/* 점(·)은 두 글자 사이 정가운데: 양쪽 여백이 같은 버튼 경계에 놓는다 */
.txt-btn + .txt-btn::before { content: "·"; position: absolute; left: 0; top: 50%; transform: translate(-50%, -50%); color: var(--faint); pointer-events: none; }
.txt-btn:hover { color: var(--text); text-decoration: none; }
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px; color: var(--text); background: none; border: 0; cursor: pointer; }
.icon-btn:hover { background: var(--band); text-decoration: none; }
.icon-btn[aria-disabled="true"] { opacity: .3; pointer-events: none; }
.tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; padding: 6px var(--gutter) 12px; }
.tabs a { text-align: center; padding: 0 2px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; background: var(--chip); font-size: 14px; font-weight: 600; color: var(--chip-ink); white-space: nowrap; position: relative; letter-spacing: -.01em; }
:lang(en) .tabs a { font-size: 13px; }
.tabs a::after { content: ""; position: absolute; inset: -4px 0; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* 본문 */
main { display: block; padding: 16px var(--gutter) 24px; min-height: 60vh; outline: none; }
.screen-head { display: flex; align-items: center; gap: 8px; }
.screen-title { font-size: 22px; line-height: 1.35; margin: 0; font-weight: 800; }
.screen-sub { margin: 4px 0 16px; color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; column-gap: 0; }
.screen-sub span, .meta span { white-space: nowrap; }
.screen-sub span + span::before, .meta span + span::before { content: "·\00a0"; padding-left: .4em; }
.empty { color: var(--muted); padding: 24px 0; margin: 0; }
.more { text-align: center; margin: 20px 0 0; }

/* 사건 목록: 왼쪽 심각도 색 막대 + 제목 + 작은 메타 (시안 8 행 모양). 넓은 화면은 두 칸 이상 */
.cards { display: grid; column-gap: 24px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.card { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); color: var(--text); min-width: 0; align-items: stretch; }
.card:hover { text-decoration: none; }
.card:hover .card-title { text-decoration: underline; text-underline-offset: 3px; }
.card-bar { width: 6px; border-radius: 3px; flex: none; background: var(--bar1); }
.sevbar-2 .card-bar { background: var(--bar2); } .sevbar-3 .card-bar { background: var(--bar3); } .sevbar-4 .card-bar { background: var(--bar4); } .sevbar-5 .card-bar { background: var(--bar5); }
.card-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.card-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.card-title { margin: 0; font-size: 16px; line-height: 1.4; font-weight: 700; }
.card-sum { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; }
.sev-txt { font-weight: 700; }
.chip { font-size: 13px; line-height: 1; padding: 6px 10px; border-radius: 999px; background: var(--chip); color: var(--chip-ink); white-space: nowrap; font-weight: 600; }
.chip-soft { background: var(--chip2); color: var(--chip2-ink); }
.rank { font-size: 14px; font-weight: 800; color: var(--link); margin-right: 6px; font-variant-numeric: tabular-nums; }
.sev { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.sev-dots { display: inline-flex; gap: 2px; }
.sev-dots i { width: 6px; height: 12px; border-radius: 2px; background: var(--line); }
.sev-1 { color: var(--sev1); } .sev-2 { color: var(--sev2); } .sev-3 { color: var(--sev3); } .sev-4 { color: var(--sev4); } .sev-5 { color: var(--sev5); }
.sev-1 .sev-dots i:nth-child(-n+1), .sev-2 .sev-dots i:nth-child(-n+2), .sev-3 .sev-dots i:nth-child(-n+3), .sev-4 .sev-dots i:nth-child(-n+4), .sev-5 .sev-dots i:nth-child(-n+5) { background: currentColor; }
.skeleton .card { height: 96px; background: var(--band); border-radius: var(--radius); border: 0; margin-bottom: 10px; }

/* 월간 사건 달력 (시안 8) */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: -4px -10px 6px; }
.cal-month { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cal-wk, .cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal-wk { font-size: 13px; color: var(--faint); text-align: center; margin-bottom: 4px; }
.cal-c { aspect-ratio: 1; min-height: 40px; border-radius: 8px; border: 0; padding: 4px 5px; font: 500 13px/1.2 var(--font); text-align: left; vertical-align: top; display: flex; align-items: flex-start; justify-content: flex-start; color: var(--h-ink); background: var(--h0); font-variant-numeric: tabular-nums; cursor: pointer; }
.cal-c.is-out { color: var(--out); cursor: default; }
.cal-c:disabled { cursor: default; color: var(--out); }
.cal-c.l0 { background: var(--h0); } .cal-c.l1 { background: var(--h1); } .cal-c.l2 { background: var(--h2); }
.cal-c.l3 { background: var(--h3); color: var(--h3-ink); } .cal-c.l4 { background: var(--h4); color: var(--h-ink-strong); }
.cal-c.is-today { font-weight: 800; text-decoration: underline; text-underline-offset: 2px; }
.cal-c.is-sel { outline: 2.5px solid var(--text); outline-offset: 1px; font-weight: 800; }
.cal-c:focus-visible { outline: 2.5px solid var(--link); outline-offset: 1px; }
.cal-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 13px; color: var(--faint); }
.cal-total { color: var(--muted); }
.cal-lg { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.cal-lg i { width: 12px; height: 12px; border-radius: 3px; }
.cal-lg .l0 { background: var(--h0); } .cal-lg .l1 { background: var(--h1); } .cal-lg .l2 { background: var(--h2); } .cal-lg .l3 { background: var(--h3); } .cal-lg .l4 { background: var(--h4); }
.day { margin: 14px 0 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.day-head h2 { margin: 0; font-size: 17px; font-weight: 800; white-space: nowrap; }
.day-head span { font-size: 13px; color: var(--muted); text-align: right; }
.day-rows { display: flex; flex-direction: column; }
.day-row { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); color: var(--text); min-height: 44px; }
.day-row:hover { text-decoration: none; }
.day-row:hover b { text-decoration: underline; text-underline-offset: 3px; }
.day-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.day-row b { font-size: 15px; line-height: 1.4; }
.day-row small { font-size: 13px; color: var(--muted); }
.digest-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 24px 0 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.digest-title { margin: 0; font-size: 20px; font-weight: 800; }
.cal-actions { display: flex; gap: 6px; }
.note { color: var(--muted); font-size: 14px; margin: 20px 0 0; padding: 12px 14px; background: var(--band); border-radius: var(--radius); }

/* 패널: 테두리 없이 위 선으로 나눈다 */
.panel { background: none; border: 0; border-top: 1px solid var(--line); margin: 0 0 8px; padding-top: 4px; }
.panel-title { margin: 0; padding: 12px 0 8px; font-size: 17px; line-height: 1.4; font-weight: 800; }
.panel-body { padding: 0 0 12px; }
.panel-body > :first-child { margin-top: 0; }
.panel-body > :last-child { margin-bottom: 0; }
.panel-list .panel-body { padding: 0; }
.sub-title { font-size: 15px; margin: 16px 0 8px; color: var(--muted); font-weight: 700; }
.lead { font-size: 17px; font-weight: 600; line-height: 1.55; }
.prose p { margin: 0 0 .7em; }
.prose-read { font-size: 17px; line-height: 1.7; }

/* 버튼·입력 */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 15px/1 var(--font); padding: 10px 16px; min-height: 44px; border-radius: 999px; border: 0; background: var(--chip); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; filter: brightness(.96); }
.btn svg { width: 18px; height: 18px; }
.btn-sm { font-size: 13px; padding: 7px 12px; min-height: 36px; min-width: 44px; }
.btn-sm::after { content: ""; position: absolute; inset: -4px 0; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:disabled { opacity: .6; cursor: default; }
input, select { font: 15px/1.3 var(--font); color: var(--text); background: var(--band); border: 1px solid transparent; border-radius: 10px; padding: 9px 10px; min-height: 44px; min-width: 0; }
input:focus, select:focus, .btn:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; }
.filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-top: 10px; }
.filters > * { min-width: 0; width: 100%; }
.filters select:nth-child(3) { grid-column: 1 / -1; }
.filters .date { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.filters .date input { width: 100%; }
.result-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; margin: 0 0 6px; min-height: 44px; }
.result-head a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }
.form-msg:empty { display: none; }
.form-msg { margin: 8px 0 0; font-size: 13px; color: var(--muted); min-height: 1.5em; }
.select.inline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }

/* 기간 탐색 */
.period-nav { display: flex; align-items: center; gap: 4px; margin: 0 0 12px; }
.period-nav .select { flex: 0 1 auto; min-width: 0; }
.period-nav .select select { width: 100%; max-width: 260px; text-overflow: ellipsis; }
.period-nav .spacer { flex: 1; }

/* 상세 */
.detail-chips { margin: -8px 0 12px; }
.detail-title { font-size: 22px; }
.share-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.thumb { aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: var(--band); margin: 0 0 12px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.links, .sources { list-style: none; margin: 0; padding: 0; }
.links li + li, .sources li + li { border-top: 1px solid var(--line); }
.links a { display: inline-flex; align-items: center; gap: 4px; padding: 8px 0; min-height: 44px; }
.links svg, .src-title svg { width: 14px; height: 14px; vertical-align: -2px; }
.sources a { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; color: var(--text); }
.sources a:hover { text-decoration: none; }
.sources a:hover .src-title { text-decoration: underline; }
.src-name { font-size: 13px; color: var(--muted); }
.src-title { font-weight: 600; color: var(--link); }
.src-quote { font-size: 13px; color: var(--muted); }

/* 그래프 */
.vbars { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 3px; align-items: end; height: 170px; }
.vbar { display: grid; grid-template-rows: 18px 1fr 20px; height: 100%; min-width: 0; text-align: center; }
.vbar-val, .vbar-lab { font-size: 13px; line-height: 18px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: visible; }
.vbar-lab { line-height: 20px; }
.vbars-cap { margin: 4px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.more-row { margin: 12px 0 4px; text-align: center; }
.more-row .btn { min-width: 60%; }
.offline-bar { padding: 8px var(--gutter); font-size: 13px; line-height: 1.4; color: var(--text); background: var(--offline, #fff4d6); border-top: 1px solid var(--line); }
.offline-bar[hidden] { display: none; }
@media (prefers-color-scheme: dark) { .offline-bar { --offline: #3a3218; } }
.vbar-track { display: flex; align-items: flex-end; }
.vbar-fill { width: 72%; margin: 0 auto; background: var(--chart); border-radius: 3px 3px 0 0; min-height: 1px; }
.hbars { display: grid; grid-template-columns: max-content minmax(40px, 1fr) 3ch; gap: 6px 8px; align-items: center; font-size: 13px; }
.hbar { display: contents; }
.hbar-lab { white-space: nowrap; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 12px; background: var(--band); border-radius: 3px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--chart); }
.hbar-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

/* 바닥글 */
.foot { padding: 8px var(--gutter) calc(32px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); margin-top: 8px; }
.foot .panel { margin-top: 8px; border-top: 0; }
.foot-links { font-size: 13px; }
.foot-links p { margin: 8px 0 0; }

.toast { border-radius: 12px; position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 10px; max-width: calc(100% - 2 * var(--gutter)); background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: 15px; box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.toast[hidden] { display: none; }
.toast { width: max-content; } /* 짧은 문구는 한 줄로, 길면 max-width 에서 꺾임 */
a.card:focus-visible { outline: 2.5px solid var(--link); outline-offset: -2px; border-radius: 8px; }

@media (min-width: 900px) {
  .filters { grid-template-columns: 1.2fr 1.2fr 1fr 1fr 1fr; align-items: end; }
  .filters select:nth-child(3) { grid-column: auto; }
}

/* 인쇄·PDF (업무 보고용) */
.print-item { padding: 10px 0; border-top: 1px solid var(--line); break-inside: avoid; }
.print-item:first-child { border-top: 0; }
.print-item h3 { margin: 0 0 4px; font-size: 16px; }
.print-src { font-size: 13px; color: var(--muted); word-break: break-all; }
.print-brand { margin: 0 0 4px; font-size: 13px; font-weight: 700; color: var(--link); }
.print-foot { font-size: 13px; color: var(--muted); }
body.print-mode .appbar, body.print-mode .foot, body.print-mode .toast { display: none; }
@media print {
  :root { --bg: #fff; --surface: #fff; --band: #f3f4f6; --line: #d9dce0; --text: #000; --muted: #444; --accent: #1f5fd1; }
  .appbar, .foot, .toast, .period-nav, .share-row { display: none !important; }
  body { font-size: 12pt; }
  main { padding: 0; }
  .panel { break-inside: auto; border-color: #ccc; }
  a { color: inherit; }
  @page { margin: 16mm 14mm; }
}

/* 관리자 */
.admin-form { display: grid; gap: 12px; }
.admin-search { margin-bottom: 12px; }
.admin-card { width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.share-row .spacer { flex: 1; }
.account { display: flex; align-items: center; gap: 6px; min-width: 0; }
.acct-email { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.field input, .field select, .field textarea { width: 100%; color: var(--text); }
textarea { font: 15px/1.5 var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.check input { min-height: 0; width: 20px; height: 20px; }
.period-nav .icon-btn, .period-nav .btn { flex: none; }
.foot-links a { display: inline-block; padding: 12px 4px; margin: -12px -4px; } /* 누르는 자리는 넓히되 글자 간격은 그대로 */
.lang-btn { min-width: 44px; justify-content: flex-start; } /* 글자를 점 쪽에 붙여 점 양쪽 간격을 같게 */
@media (max-width: 379px) { .period-nav .btn-label { display: none; } .period-nav select { font-size: 14px; padding: 9px 4px 9px 8px; } .period-nav { gap: 2px; } .period-nav .btn-sm { padding: 7px 10px; } }
