:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1d1f24; --muted: #646a73; --line: #e2e0d9;
  --accent: #1f4e8c; --accent-soft: #e6eef8;
  --red: #b42318; --red-soft: #fdecea; --amber: #a15c07; --amber-soft: #fef4e2;
  --green: #217a46; --green-soft: #e7f5ec; --info: #4a5568; --info-soft: #eef0f3;
  --radius: 10px;
  font-family: "Pretendard", "Noto Sans KR", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418; --panel: #1b1e24; --ink: #e8e9ec; --muted: #9aa1ac; --line: #2c313a;
    --accent: #7fb0f0; --accent-soft: #1c2a3d;
    --red: #f2837a; --red-soft: #3a1d1b; --amber: #f0b45c; --amber-soft: #382a14;
    --green: #6cc995; --green-soft: #17301f; --info: #b4bcc8; --info-soft: #252a32;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.6; word-break: keep-all; }
a { color: var(--accent); }
/* ── 레이아웃: 왼쪽 사이드 메뉴 + 본문 ── */
:root { --side-w: 264px; }
.shell { display: flex; min-height: 100vh; }
.side { width: var(--side-w); flex: 0 0 var(--side-w); background: var(--panel); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; padding: 18px 12px 14px; }
.side-brand { padding: 0 8px 14px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.side-brand b { display: block; font-size: 17px; }
.side-brand span { font-size: 12.5px; color: var(--muted); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav button, .side-cos button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; font: inherit; font-size: 14.5px;
  color: var(--ink); background: none; border: 0; border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.side-nav button:hover, .side-cos button:hover { background: var(--bg); }
.side-nav button.on, .side-cos button.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.side-nav .ic { width: 18px; text-align: center; color: var(--muted); }
.side-nav button.on .ic { color: var(--accent); }
.side-sec { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 4px; padding: 0 10px;
  font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.side-add { font: inherit; font-size: 15px; line-height: 1; border: 1px solid var(--line); background: none; color: var(--accent); border-radius: 6px; width: 26px; height: 26px; cursor: pointer; }
.side-add:hover { background: var(--accent-soft); }
.side-cos { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.side-cos .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-cos .sc { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.dot.g-정상 { background: var(--green); } .dot.g-관찰 { background: var(--info); }
.dot.g-치료 { background: var(--amber); } .dot.g-집중치료 { background: var(--red); }
.side-foot { margin-top: auto; padding: 14px 10px 0; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.main-wrap { flex: 1; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.crumb { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb b { color: var(--ink); }
.crumb button { font: inherit; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; }
.crumb button:hover { color: var(--accent); }
.menu-btn { display: none; font-size: 20px; line-height: 1; background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 8px; width: 38px; height: 38px; cursor: pointer; }
.scrim { display: none; }
main { max-width: 1180px; margin: 0 auto; padding: 22px 24px 60px; }
/* 기업 차트 안 섹션 바로가기 */
.secnav { position: sticky; top: 52px; z-index: 3; display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 10px; margin-bottom: 8px;
  background: var(--bg); scrollbar-width: none; }
.secnav::-webkit-scrollbar { display: none; }
.secnav a { flex: 0 0 auto; font-size: 13px; text-decoration: none; color: var(--muted); border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 12px; }
.secnav a:hover, .secnav a.on { color: var(--accent); border-color: var(--accent); }
.panel[id], .grid[id] { scroll-margin-top: 110px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 13.5px; padding-top: 10px; }
@media (max-width: 900px) {
  .side { position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
  .shell.open .side { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .shell.open .scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,.35); }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { padding: 8px 16px; }
  main { padding: 18px 16px 60px; }
}
h2 { font-size: 20px; margin: 4px 0 14px; }
h3 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--accent-soft); }
.scroll { overflow-x: auto; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.g-정상 { background: var(--green-soft); color: var(--green); }
.g-관찰 { background: var(--info-soft); color: var(--info); }
.g-치료 { background: var(--amber-soft); color: var(--amber); }
.g-집중치료 { background: var(--red-soft); color: var(--red); }
.lv-red { background: var(--red-soft); color: var(--red); }
.lv-amber { background: var(--amber-soft); color: var(--amber); }
.lv-info { background: var(--info-soft); color: var(--info); }
.lv-ok { background: var(--green-soft); color: var(--green); }
.finding { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.finding:last-child { border-bottom: 0; }
.finding .t { font-weight: 700; }
.finding .act { grid-column: 2; font-size: 14px; }
.finding .col { grid-column: 2; font-size: 12.5px; color: var(--muted); }
.co-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 14px; }
.co-head h2 { margin: 0; }
.co-head .meta { color: var(--muted); font-size: 14px; }
.score { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
form.f { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 12px; margin-top: 12px; }
form.f label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
form.f label.wide { grid-column: 1 / -1; }
form.f .sect { grid-column: 1 / -1; font-weight: 700; color: var(--ink); font-size: 13.5px; margin-top: 6px; }
input, select, textarea { font: inherit; font-size: 14px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; width: 100%; }
textarea { min-height: 60px; resize: vertical; }
button.btn { font: inherit; font-size: 14px; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 7px; padding: 8px 14px; cursor: pointer; }
button.btn.ghost { background: none; color: var(--accent); }
button.btn.sm { padding: 4px 10px; font-size: 13px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.f .row-actions { grid-column: 1 / -1; }
details.add { margin-top: 10px; }
details.add summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.colcard { border-top: 1px solid var(--line); padding: 14px 0; }
.colcard:first-of-type { border-top: 0; }
.colcard .d { color: var(--muted); font-size: 12.5px; }
.colcard h4 { margin: 2px 0 6px; font-size: 15.5px; }
.colcard p { margin: 4px 0; font-size: 14px; }
.colcard .ap { background: var(--accent-soft); border-radius: 7px; padding: 8px 10px; }
.chip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); margin-right: 4px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 14px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 16px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
svg.chart { width: 100%; max-width: 760px; height: auto; display: block; }
.co-head select { width: auto; max-width: 220px; }
svg.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 3px; vertical-align: middle; margin-right: 5px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.notice { font-size: 13px; color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
@media (max-width: 640px) {
  .kv { grid-template-columns: 1fr; }
  .finding { grid-template-columns: 1fr; }
  .finding .act, .finding .col { grid-column: 1; }
}
@media print { .side, .topbar, .secnav, details.add, button { display: none !important; } body { background: #fff; } }
/* ── 우측 상단 로그인 ── */
.topbar .crumb { flex: 1; min-width: 0; }
.auth { margin-left: auto; position: relative; flex: 0 0 auto; }
.auth .who { display: flex; align-items: center; gap: 8px; font: inherit; font-size: 13.5px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 6px; cursor: pointer; max-width: 260px; }
.auth .who .av { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex: 0 0 24px; }
.auth .who .em { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth .menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); padding: 6px; z-index: 30; }
.auth .menu p { margin: 6px 10px 8px; font-size: 12.5px; color: var(--muted); }
.auth .menu button { display: block; width: 100%; text-align: left; font: inherit; font-size: 14px; color: var(--ink); background: none; border: 0; border-radius: 7px; padding: 8px 10px; cursor: pointer; }
.auth .menu button:hover { background: var(--bg); }
.auth .tag { font-size: 12px; color: var(--muted); margin-right: 8px; }
dialog.login { width: min(400px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink); padding: 24px; }
dialog.login::backdrop { background: rgba(0,0,0,.4); }
dialog.login h2 { margin: 0 0 4px; }
.login-close { position: absolute; top: 10px; right: 10px; }
.login-close button { background: none; border: 0; font-size: 16px; color: var(--muted); cursor: pointer; padding: 6px; }
.login-step[hidden] { display: none; }
.login-step { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.login-step label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-step input[name=code] { font-size: 22px; letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.linkbtn { font: inherit; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; }
.login-msg { min-height: 1.4em; margin: 12px 0 0; font-size: 13.5px; }
.login-msg.err { color: var(--red); } .login-msg.ok { color: var(--green); }
@media (max-width: 520px) { .auth .who .em, .auth .tag { display: none; } .auth .who { padding: 5px; } }
