:root {
  --font: "Pretendard", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
  --bg: #f3f4f6; --panel: #ffffff; --line: #d9dce1; --line2: #e9ebee;
  --text: #1c2026; --sub: #5b6470; --mute: #8a929c;
  --brand: #1f4e8c; --brand-2: #173c6c; --brand-bg: #e8eef7;
  --ok: #1d7a46; --ok-bg: #e5f3ea; --warn: #9a5b00; --warn-bg: #fdf1dc; --bad: #b3261e; --bad-bg: #fbe7e5;
  --side: #20262e; --side-text: #c9d0d8; --side-act: #2f3843;
  --row-hover: #f6f8fb; --top: #1d3f6e;
}
:root[data-theme="dark"] {
  --bg: #15181c; --panel: #1d2126; --line: #343a42; --line2: #2a2f36;
  --text: #e4e7eb; --sub: #a3abb5; --mute: #7a838d;
  --brand: #5b8fd6; --brand-2: #7aa6e2; --brand-bg: #22324a;
  --ok: #5cc28a; --ok-bg: #1d3327; --warn: #e0a54a; --warn-bg: #3a2e1a; --bad: #f08a80; --bad-bg: #3d2322;
  --side: #111417; --side-text: #aab2bb; --side-act: #222830; --row-hover: #232830; --top: #182536;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 13px/1.5 var(--font); color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }

/* 레이아웃 */
.app { display: grid; grid-template-columns: 208px 1fr; grid-template-rows: 44px 1fr 24px; height: 100vh; }
.top { grid-column: 1 / 3; display: flex; align-items: center; gap: 12px; padding: 0 14px; background: var(--top); color: #fff; }
.top .name { font-weight: 700; font-size: 14px; letter-spacing: -0.2px; }
.top .name small { font-weight: 400; opacity: .75; margin-left: 6px; }
.top .sp { flex: 1; }
.top .u { opacity: .9; }
.top button { background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff; padding: 3px 10px; border-radius: 2px; cursor: pointer; }
.top button:hover { background: rgba(255,255,255,.12); }
.side { background: var(--side); color: var(--side-text); overflow: auto; padding: 8px 0; }
.side .grp { font-size: 11px; color: #7d8792; padding: 10px 16px 4px; }
.side a { display: block; padding: 6px 16px 6px 22px; color: var(--side-text); text-decoration: none; border-left: 3px solid transparent; }
.side a:hover { background: var(--side-act); }
.side a.on { background: var(--side-act); color: #fff; border-left-color: #6fa3e8; }
.main { overflow: auto; padding: 16px 20px 28px; }
.status { grid-column: 1 / 3; display: flex; gap: 18px; align-items: center; padding: 0 12px; font-size: 11px; color: var(--sub); background: var(--panel); border-top: 1px solid var(--line); }

/* 공통 요소 */
h1 { font-size: 17px; margin: 0 0 2px; }
.desc { color: var(--sub); margin: 0 0 12px; }
.bar { display: flex; gap: 6px; align-items: center; margin: 0 0 10px; flex-wrap: wrap; }
.bar .sp { flex: 1; }
.btn { border: 1px solid var(--line); background: var(--panel); padding: 4px 12px; border-radius: 2px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.sm { padding: 1px 8px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: default; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], input[type=search], select, textarea {
  border: 1px solid var(--line); background: var(--panel); padding: 4px 7px; border-radius: 2px; min-height: 27px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-bg); }
textarea { width: 100%; resize: vertical; }
.panel { background: var(--panel); border: 1px solid var(--line); margin-bottom: 14px; }
.panel > .ph { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line2); font-weight: 700; }
.panel > .ph .sp { flex: 1; }
.panel > .pb { padding: 12px; }
table.t { width: 100%; border-collapse: collapse; background: var(--panel); }
table.t th, table.t td { border-bottom: 1px solid var(--line2); padding: 6px 8px; text-align: left; vertical-align: middle; }
table.t th { white-space: nowrap; background: var(--bg); color: var(--sub); font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1; }
table.t tr:hover td { background: var(--row-hover); }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t td.act { white-space: nowrap; text-align: right; }
.tw { border: 1px solid var(--line); max-height: calc(100vh - 210px); overflow: auto; }
.empty { padding: 28px; text-align: center; color: var(--mute); }
.tag { display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-radius: 2px; font-size: 11px; line-height: 18px; color: var(--sub); white-space: nowrap; }
.tag.ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.tag.warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.tag.bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.tag.blue { color: var(--brand); background: var(--brand-bg); border-color: transparent; }
.mute { color: var(--mute); }
.mono { font-family: Consolas, "D2Coding", monospace; font-size: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); padding: 10px 12px; }
.kpi .l { color: var(--sub); font-size: 12px; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .v.bad { color: var(--bad); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.form { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; align-items: center; }
.form label.l { color: var(--sub); text-align: right; }
.form .full { grid-column: 1 / 3; }
.hint { color: var(--mute); font-size: 12px; }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs a { padding: 6px 14px; cursor: pointer; color: var(--sub); border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.bars { display: flex; height: 8px; background: var(--line2); margin-top: 4px; }
.bars span { display: block; height: 100%; }

/* 권한 매트릭스 */
.mx td.c { text-align: center; cursor: pointer; user-select: none; width: 86px; }
.mx td.c .x { display: inline-block; min-width: 40px; padding: 0 4px; border-radius: 2px; font-size: 12px; }
.mx td.c .x.y { color: var(--ok); }
.mx td.c .x.n { color: var(--mute); }
.mx td.c .x.ey { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.mx td.c .x.en { background: var(--bad-bg); color: var(--bad); font-weight: 600; }

/* 대화상자 */
#dlg .bg { position: fixed; inset: 0; background: rgba(15,20,26,.45); display: flex; align-items: flex-start; justify-content: center; padding-top: 8vh; z-index: 50; }
.dlg { background: var(--panel); border: 1px solid var(--line); width: 520px; max-width: calc(100vw - 32px); max-height: 84vh; display: flex; flex-direction: column; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.dlg.wide { width: 760px; }
.dlg-h { padding: 10px 14px; font-weight: 700; border-bottom: 1px solid var(--line2); display: flex; }
.dlg-h .sp { flex: 1; }
.dlg-h .x { cursor: pointer; color: var(--mute); border: 0; background: none; font-size: 16px; line-height: 1; }
.dlg-b { padding: 14px; overflow: auto; }
.dlg-f { padding: 10px 14px; border-top: 1px solid var(--line2); display: flex; gap: 6px; justify-content: flex-end; }
.err { color: var(--bad); background: var(--bad-bg); padding: 6px 10px; margin-bottom: 10px; }
.note { background: var(--brand-bg); padding: 8px 10px; margin-bottom: 10px; }
.secret { font-family: Consolas, monospace; font-size: 15px; padding: 8px 10px; background: var(--bg); border: 1px dashed var(--line); user-select: all; }
.prog { height: 6px; background: var(--line2); margin-top: 8px; } .prog i { display: block; height: 100%; background: var(--brand); width: 0; }
#toast { position: fixed; right: 16px; bottom: 36px; z-index: 60; display: flex; flex-direction: column; gap: 6px; }
#toast div { background: #26303b; color: #fff; padding: 8px 14px; border-radius: 2px; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
#toast div.bad { background: var(--bad); }

/* 로그인 */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login .box { width: 360px; background: var(--panel); border: 1px solid var(--line); }
.login .hd { background: var(--top); color: #fff; padding: 16px 20px; }
.login .hd b { font-size: 16px; display: block; }
.login .hd span { opacity: .75; font-size: 12px; }
.login .bd { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 10px; }
.login input { width: 100%; min-height: 34px; }
.login .btn { min-height: 34px; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 44px auto 1fr 24px; }
  .side { display: flex; overflow-x: auto; padding: 0; }
  .side .grp { display: none; }
  .side a { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; padding: 8px 12px; }
  .side a.on { border-bottom-color: #6fa3e8; }
  .top, .status { grid-column: 1; }
  .top .u, .top .name small { display: none; }
  .top button { white-space: nowrap; padding: 3px 7px; }
  .form { grid-template-columns: 1fr; } .form label.l { text-align: left; } .form .full { grid-column: 1; }
}
