/* KDHC-AX 통합운영시스템 프로토타입 — 디자인 시스템 */
:root {
  --kdhc: #e8531a;          /* KDHC 레드오렌지 */
  --kdhc-dark: #c23d0c;
  --navy: #0f1b2d;
  --navy-2: #16263c;
  --navy-3: #1e3350;
  --blue: #2563eb;
  --teal: #0e9f8e;
  --green: #16a34a;
  --amber: #f59e0b;
  --red: #dc2626;
  --purple: #7c3aed;
  --slate: #64748b;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #eef2f7;
  --bg: #f4f6fa;
  --card: #ffffff;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.05);
  --shadow-lg: 0 8px 30px rgba(15,23,42,.12);
  --r: 12px;
  --sidebar-w: 256px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard',
    'Malgun Gothic', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #c6d0dd; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #aab7c7; }

/* ── 레이아웃 ───────────────────────────────────── */
#app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy) 0%, #0b1422 100%);
  color: #cdd7e4; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.brand {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px;
  background: linear-gradient(135deg, var(--kdhc), #ff7a45);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: 0 4px 12px rgba(232,83,26,.4);
}
.brand .t1 { font-size: 13px; font-weight: 800; color: #fff; letter-spacing: .2px; }
.brand .t2 { font-size: 10.5px; color: #8aa0bb; margin-top: 1px; }
.nav { flex: 1; overflow-y: auto; padding: 8px 8px 24px; }
.nav::-webkit-scrollbar-thumb { background: #2a3a52; }
.nav-group-label {
  font-size: 10px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  color: #5d7390; padding: 14px 12px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 11px; border-radius: 8px;
  cursor: pointer; color: #b8c5d6; font-size: 12.5px; font-weight: 500; margin: 1px 0;
  transition: background .12s, color .12s; white-space: nowrap;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(232,83,26,.22), rgba(232,83,26,.05)); color: #fff; box-shadow: inset 2px 0 0 var(--kdhc); }
.nav-item .ico { width: 17px; text-align: center; flex: 0 0 17px; opacity: .9; font-size: 13px; }
.nav-item .badge-mini { margin-left: auto; font-size: 9.5px; background: rgba(255,255,255,.12); padding: 1px 6px; border-radius: 9px; color: #d6e0ec; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 20px; position: sticky; top: 0; z-index: 30;
}
.crumb { font-size: 12px; color: var(--muted); }
.crumb b { color: var(--ink); font-weight: 700; font-size: 14px; }
.topbar .spacer { flex: 1; }
.zone-pills { display: flex; gap: 6px; }
.zone-pill { font-size: 11px; padding: 3px 9px; border-radius: 20px; border: 1px solid var(--line); color: var(--muted); display: flex; align-items: center; gap: 5px; }
.zone-pill .dot { width: 7px; height: 7px; border-radius: 50%; }
.env-badge { font-size: 10.5px; font-weight: 800; letter-spacing: .5px; color: #fff; background: var(--green); padding: 3px 8px; border-radius: 5px; }
.clock { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.user-chip .av { width: 28px; height: 28px; border-radius: 50%; background: var(--navy-3); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 11px; }

.content { padding: 18px 22px 60px; max-width: 1640px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 19px; margin: 0; font-weight: 800; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); font-size: 12.5px; }
.page-head .rfp-tags { margin-left: auto; display: flex; gap: 5px; flex-wrap: wrap; }

/* ── 그리드 유틸 ─────────────────────────────────── */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g6 { grid-template-columns: repeat(6, 1fr); }
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
@media (max-width: 1200px){ .g4{grid-template-columns:repeat(2,1fr);} .g6{grid-template-columns:repeat(3,1fr);} .g3{grid-template-columns:1fr 1fr;} }

/* ── 카드 ───────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 8px; padding: 12px 15px; border-bottom: 1px solid var(--line-2); }
.card-h h3 { margin: 0; font-size: 13.5px; font-weight: 700; }
.card-h .hint { font-size: 11px; color: var(--muted); }
.card-h .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-b { padding: 14px 15px; }
.card-b.tight { padding: 8px 10px; }

/* KPI */
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 13px 15px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi .label { font-size: 11.5px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 25px; font-weight: 800; margin-top: 6px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi .val .u { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.kpi .delta { font-size: 11.5px; font-weight: 700; margin-top: 3px; }
.kpi .delta.up { color: var(--green); }
.kpi .delta.down { color: var(--red); }
.kpi .delta.flat { color: var(--muted); }
.kpi .spark { position: absolute; right: 10px; bottom: 8px; opacity: .85; }
.kpi .accent { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }

/* 배지/상태 */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px; line-height: 1.6; white-space: nowrap; }
.badge.gray { background: #eef1f5; color: #475569; }
.badge.blue { background: #e0ecff; color: #1d4ed8; }
.badge.green { background: #dcfce7; color: #15803d; }
.badge.amber { background: #fef3c7; color: #b45309; }
.badge.red { background: #fee2e2; color: #b91c1c; }
.badge.teal { background: #ccfbf1; color: #0f766e; }
.badge.purple { background: #ede9fe; color: #6d28d9; }
.badge.kdhc { background: #ffe8dd; color: var(--kdhc-dark); }
.dot-st { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.tag { display: inline-block; font-size: 10px; font-weight: 700; font-family: ui-monospace, Menlo, monospace; padding: 2px 6px; border-radius: 5px; background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.tag.rfp { background: #fff1ea; color: var(--kdhc-dark); border-color: #ffd9c6; cursor: pointer; }
.tag.rfp:hover { background: #ffe2d2; }

/* 테이블 */
.tbl-wrap { overflow: auto; border-radius: 8px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
table.tbl th { text-align: left; font-weight: 700; color: #56657a; background: #f7f9fc; padding: 8px 11px; border-bottom: 1px solid var(--line); position: sticky; top: 0; white-space: nowrap; font-size: 11.5px; }
table.tbl td { padding: 7px 11px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.tbl tr:hover td { background: #fafcff; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl.zebra tbody tr:nth-child(even) td { background: #fbfcfe; }

/* 탭 */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tab { padding: 8px 14px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--kdhc); border-bottom-color: var(--kdhc); }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.subtab { padding: 5px 11px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--line); border-radius: 20px; color: var(--muted); cursor: pointer; background: #fff; }
.subtab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* 버튼 */
.btn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); cursor: pointer; }
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--kdhc); color: #fff; border-color: var(--kdhc); }
.btn.primary:hover { background: var(--kdhc-dark); }
.btn.ghost { border-color: transparent; background: #f1f5f9; }
.btn.sm { padding: 4px 9px; font-size: 11px; }

/* 진행바/게이지 */
.pbar { height: 7px; background: #eef2f7; border-radius: 6px; overflow: hidden; }
.pbar > span { display: block; height: 100%; border-radius: 6px; }

/* 스텝퍼 (상태머신/워크플로) */
.stepper { display: flex; align-items: center; gap: 0; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; }
.step .node { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; border: 2px solid var(--line); color: var(--muted); background: #fff; }
.step.done .node { background: var(--green); border-color: var(--green); color: #fff; }
.step.active .node { background: var(--kdhc); border-color: var(--kdhc); color: #fff; box-shadow: 0 0 0 4px rgba(232,83,26,.15); }
.step .lbl { font-size: 11.5px; font-weight: 600; }
.step.todo .lbl { color: var(--muted); }
.step .bar { width: 34px; height: 2px; background: var(--line); margin: 0 4px; }
.step.done .bar { background: var(--green); }

/* 다이어그램 (아키텍처/망분리/DB) */
.diagram { display: flex; flex-direction: column; gap: 14px; }
.zone { border: 1.5px dashed #cbd5e1; border-radius: 12px; padding: 12px 14px; position: relative; }
.zone .zlabel { position: absolute; top: -10px; left: 14px; background: #fff; padding: 0 8px; font-size: 11px; font-weight: 700; }
.node-box { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; box-shadow: var(--shadow); font-size: 11.5px; }
.node-box .nt { font-weight: 700; font-size: 12px; }
.node-box .nd { color: var(--muted); font-size: 10.5px; margin-top: 2px; }
.node-box .pill { font-size: 9.5px; padding: 1px 6px; border-radius: 10px; background: #eef2f7; color: #475569; margin-top: 5px; display: inline-block; }
.layer-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.layer-row .lc { width: 50px; flex: 0 0 50px; text-align: center; font-family: ui-monospace, monospace; font-weight: 700; font-size: 11px; padding: 4px; border-radius: 6px; color: #fff; }

/* 차트 */
.chart svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--ink-2); }
.legend .li { display: flex; align-items: center; gap: 5px; }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; }

/* 리스트/메타 */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.alarm-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 12px; }
.note { font-size: 11.5px; color: var(--muted); }
.callout { background: #fff8f3; border: 1px solid #ffd9c6; border-left: 3px solid var(--kdhc); border-radius: 8px; padding: 10px 13px; font-size: 12px; color: #7a3f1d; }

.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 14px; max-width: 640px; width: 100%; max-height: 80vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal-h { padding: 15px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-b { padding: 16px 18px; }
.x { margin-left: auto; cursor: pointer; color: var(--muted); font-size: 18px; }

.filterbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.inp, select.inp { font-size: 12px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: #fff; padding: 6px 12px; font-size: 12px; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg button.active { background: var(--ink); color: #fff; }

/* ── ERD 모델링 UI ─────────────────────────────── */
.erd-wrap { display: grid; grid-template-columns: 1fr 280px; gap: 12px; align-items: start; }
.erd-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.erd-areas { display: flex; gap: 5px; flex-wrap: wrap; }
.erd-areachip { font-size: 10.5px; padding: 3px 8px; border-radius: 20px; border: 1px solid var(--line); cursor: pointer; user-select: none; display: flex; align-items: center; gap: 5px; background:#fff; }
.erd-areachip .sw { width: 9px; height: 9px; border-radius: 50%; }
.erd-areachip.off { opacity: .4; text-decoration: line-through; }
.erd-canvas { position: relative; overflow: auto; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; height: 640px;
  background-image: radial-gradient(#e2e8f0 1px, transparent 1px); background-size: 22px 22px; }
.erd-inner { position: relative; }
.erd-svg { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.erd-entity { position: absolute; width: 212px; background: #fff; border: 1px solid #cbd5e1; border-radius: 9px; box-shadow: 0 2px 8px rgba(15,23,42,.1); font-size: 11px; z-index: 2; }
.erd-entity.sel { border-color: var(--kdhc); box-shadow: 0 0 0 3px rgba(232,83,26,.22); z-index: 5; }
.erd-entity .eh { padding: 6px 9px; border-radius: 8px 8px 0 0; color: #fff; cursor: move; display: flex; flex-direction: column; gap: 1px; }
.erd-entity .eh .l { font-weight: 800; font-size: 11.5px; }
.erd-entity .eh .n { font-size: 9.5px; opacity: .85; font-family: ui-monospace, Menlo, monospace; }
.erd-entity .eb { padding: 3px 0; }
.erd-col2 { display: flex; align-items: center; gap: 6px; padding: 2px 9px; }
.erd-col2:hover { background: #f1f5f9; }
.erd-col2 .k { width: 18px; font-size: 8.5px; font-weight: 800; color: #b45309; text-align: center; }
.erd-col2 .k.pk { color: #b45309; }
.erd-col2 .k.fk { color: #2563eb; }
.erd-col2 .cn { flex: 1; font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; color: #334155; }
.erd-col2 .cn.pkk { font-weight: 700; text-decoration: underline; }
.erd-col2 .ct { font-size: 9.5px; color: #94a3b8; }
.erd-side { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; position: sticky; top: 70px; max-height: 660px; overflow: auto; box-shadow: var(--shadow); }
.erd-side h4 { margin: 0 0 8px; font-size: 13px; }
.erd-side .fld { margin-bottom: 8px; }
.erd-side .fld label { font-size: 10.5px; color: var(--muted); display: block; margin-bottom: 2px; }
.erd-side .inp, .erd-side select.inp { width: 100%; font-size: 11.5px; padding: 4px 7px; }
.erd-colrow { display: grid; grid-template-columns: 1fr auto; gap: 4px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line-2); }
.erd-colrow .crn { font-family: ui-monospace, monospace; font-size: 11px; }
.erd-colrow .crt { font-size: 9.5px; color: var(--muted); }
.erd-colrow .flags { display: flex; gap: 3px; }
.erd-mini { font-size: 9px; padding: 1px 4px; border-radius: 4px; border: 1px solid var(--line); cursor: pointer; background:#fff; color:#64748b; }
.erd-mini.on { background: var(--kdhc); color: #fff; border-color: var(--kdhc); }
.ddl-pre { background: #0f1b2d; color: #cdd7e4; padding: 14px 16px; border-radius: 10px; overflow: auto; font-size: 11.5px; line-height: 1.6; max-height: 620px; font-family: ui-monospace, Menlo, monospace; }
.ddl-pre .kw { color: #ff8a5c; font-weight: 700; }
.ddl-pre .cm { color: #6b8299; }
.ddl-pre .ty { color: #7dd3fc; }
@media (max-width: 1100px) { .erd-wrap { grid-template-columns: 1fr; } }
