:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e3e8ef;
  --line-strong: #cbd5e1;
  --text: #1b2430;
  --text-dim: #5b6b7f;
  --text-mute: #8b98a8;
  --brand: #2f5bd7;
  --brand-dark: #23459f;
  --brand-soft: #eaf0ff;
  --ok: #1f9254;
  --warn: #b3730a;
  --danger: #c1352f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 18px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR",
    system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.mock-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 900;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: repeating-linear-gradient(45deg, #232a36, #232a36 10px, #2b3443 10px, #2b3443 20px);
  color: #ffd66b;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
}

.app-root { padding-top: 30px; min-height: 100vh; }

/* ---------- 로그인 ---------- */
.login-wrap {
  min-height: calc(100vh - 30px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background:
    radial-gradient(1000px 460px at 12% -10%, #dfe8ff 0%, transparent 60%),
    radial-gradient(900px 420px at 100% 110%, #e6f4ee 0%, transparent 55%);
}
.login-card {
  width: 100%;
  max-width: 880px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  overflow: hidden;
}
.login-left { padding: 40px 36px; }
.login-right { padding: 40px 36px; background: var(--surface-2); border-left: 1px solid var(--line); }
.login-title { font-size: 24px; font-weight: 800; margin: 0 0 6px; letter-spacing: -.02em; }
.login-sub { color: var(--text-dim); margin: 0 0 26px; }
.preset-list { display: grid; gap: 10px; }
.preset-btn {
  text-align: left; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 12px 14px; cursor: pointer; transition: .12s;
}
.preset-btn:hover { border-color: var(--brand); background: var(--brand-soft); }
.preset-btn strong { display: block; font-size: 14px; }
.preset-btn span { color: var(--text-dim); font-size: 12px; }

/* ---------- 레이아웃 ---------- */
.shell { display: flex; min-height: calc(100vh - 30px); }
.sidebar {
  width: 236px; flex: none; background: #16202e; color: #c9d4e2;
  display: flex; flex-direction: column; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--brand);
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px;
}
.brand-text { font-weight: 700; color: #fff; font-size: 14px; letter-spacing: -.01em; }
.brand-text small { display: block; font-weight: 500; color: #7f8ea3; font-size: 11px; }
.nav-group-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: #6b7b90; margin: 16px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 8px;
  color: #c9d4e2; font-size: 13.5px; cursor: pointer; border: none; background: none;
  width: 100%; text-align: left;
}
.nav-item:hover { background: #22303f; color: #fff; text-decoration: none; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 700; }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; font-size: 14px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; flex: none; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
}
.topbar-title { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.topbar-spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-dim); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand-dark); display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.content { padding: 22px; flex: 1; }
.page-head { margin-bottom: 16px; }
.page-head h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--text-dim); font-size: 13px; }

/* ---------- 카드 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden;
}
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.card-head .sub { color: var(--text-mute); font-size: 12px; font-weight: 500; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .label { color: var(--text-dim); font-size: 12.5px; }
.stat .value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.stat .value small { font-size: 13px; font-weight: 600; color: var(--text-mute); margin-left: 3px; }
.stat .foot { color: var(--text-mute); font-size: 12px; margin-top: 2px; }

/* ---------- 표 ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th, table.tbl td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); }
table.tbl thead th {
  background: var(--surface-2); color: var(--text-dim); font-weight: 700; font-size: 12.5px;
  white-space: nowrap; position: sticky; top: 0;
}
table.tbl tbody tr:hover { background: #f7f9fd; }
table.tbl tbody tr.selected { background: var(--brand-soft); }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl tfoot td { background: var(--surface-2); font-weight: 700; }
.table-scroll { max-height: 460px; overflow: auto; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); cursor: pointer; font-size: 13.5px; font-weight: 600;
  transition: .12s; white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand-dark); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); color: #fff; }
.btn.danger { color: var(--danger); border-color: #e9bdb9; background: #fff; }
.btn.danger:hover { background: #fdf0ef; border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-dim); }
.btn.ghost:hover { background: var(--surface-2); color: var(--brand-dark); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- 폼 ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-dim); margin-bottom: 5px; }
.input, .select, .textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: #fff; outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,91,215,.12); }
.textarea { resize: vertical; min-height: 62px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }

/* ---------- 배지 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; border: 1px solid transparent; white-space: nowrap;
}
.badge.grade { min-width: 30px; justify-content: center; }
.g-S { background: #efe4ff; color: #6b2fb5; border-color: #d9c2ff; }
.g-A { background: #e2f6ea; color: #1a7a47; border-color: #bfe8d1; }
.g-B { background: #e4eeff; color: #2350b8; border-color: #c6daff; }
.g-C { background: #fdf3dd; color: #96650a; border-color: #f2ddb0; }
.g-D { background: #fdeae9; color: #b3312b; border-color: #f5c9c6; }
.tone-gray { background: #eef1f5; color: #55637a; }
.tone-blue { background: #e4eeff; color: #2350b8; }
.tone-green { background: #e2f6ea; color: #1a7a47; }
.tone-amber { background: #fdf3dd; color: #96650a; }
.tone-red { background: #fdeae9; color: #b3312b; }
.tone-purple { background: #efe4ff; color: #6b2fb5; }

/* ---------- 척도 라디오 ---------- */
.scale { display: flex; gap: 8px; flex-wrap: wrap; }
.scale label {
  display: flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line-strong);
  border-radius: 8px; cursor: pointer; font-size: 13px; background: #fff;
}
.scale label:hover { border-color: var(--brand); }
.scale label.on { border-color: var(--brand); background: var(--brand-soft); font-weight: 700; }
.scale input { margin: 0; }

/* ---------- 차트 ---------- */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 76px; align-items: center; gap: 10px; font-size: 13px; }
.bar-track { height: 16px; background: #eef1f6; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #4a7ae8, #2f5bd7); border-radius: 999px; }
.bar-fill.alt { background: linear-gradient(90deg, #35b37e, #1f9254); }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-dim); font-weight: 600; }

.hist { display: flex; align-items: flex-end; gap: 8px; height: 190px; padding-top: 20px; }
.hist .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.hist .col .n { font-size: 11.5px; color: var(--text-dim); font-weight: 600; }
.hist .col .bar { width: 100%; max-width: 54px; background: linear-gradient(180deg, #4a7ae8, #2f5bd7); border-radius: 6px 6px 0 0; min-height: 2px; }
.hist .col .lb { font-size: 11.5px; color: var(--text-mute); }

.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.legend { display: grid; gap: 7px; font-size: 13px; }
.legend .li { display: flex; align-items: center; gap: 8px; }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; }

/* ---------- 진행바 ---------- */
.meter { height: 10px; border-radius: 999px; background: #eef1f6; overflow: hidden; min-width: 90px; }
.meter > i { display: block; height: 100%; background: var(--brand); }

/* ---------- 기타 ---------- */
.notice {
  border: 1px solid var(--line); border-left: 4px solid var(--brand); background: var(--brand-soft);
  border-radius: 8px; padding: 12px 14px; font-size: 13px; color: #24365e;
}
.notice.warn { border-left-color: var(--warn); background: #fdf7e8; color: #7a5408; }
.notice.danger { border-left-color: var(--danger); background: #fdf0ef; color: #8f2723; }
.notice.ok { border-left-color: var(--ok); background: #eaf7f0; color: #14613a; }
.muted { color: var(--text-mute); }
.dim { color: var(--text-dim); }
.empty { padding: 46px 18px; text-align: center; color: var(--text-mute); }
.empty .big { font-size: 30px; opacity: .5; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }
.mt16 { margin-top: 16px; }
.stack { display: grid; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hr { height: 1px; background: var(--line); margin: 14px 0; border: 0; }
.help { font-size: 12px; color: var(--text-mute); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(16px);
  background: #1b2430; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: .18s; z-index: 1200; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 1100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 460px; box-shadow: var(--shadow);
  overflow: hidden;
}
.modal h3 { margin: 0; padding: 16px 18px; font-size: 15px; border-bottom: 1px solid var(--line); }
.modal .body { padding: 18px; color: var(--text-dim); font-size: 13.5px; }
.modal .foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.modal.wide { max-width: 680px; }

.forbidden { padding: 60px 20px; text-align: center; }
.forbidden .code { font-size: 44px; font-weight: 800; color: var(--danger); letter-spacing: -.03em; }
.forbidden p { color: var(--text-dim); }

@media (max-width: 1080px) {
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .login-card { grid-template-columns: 1fr; }
  .login-right { border-left: 0; border-top: 1px solid var(--line); }
  .sidebar { width: 64px; padding: 14px 8px; }
  .brand-text, .nav-item .txt, .nav-group-title { display: none; }
  .nav-item { justify-content: center; }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 14px; }
}

/* ---------- 도움말 채팅 ---------- */
.help-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 940;
  border: 0; border-radius: 999px; padding: 10px 16px;
  background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; box-shadow: var(--shadow);
}
.help-fab:hover { background: var(--brand-dark); }
.help-fab:focus-visible, .help-chip:focus-visible { outline: 2px solid var(--brand-dark); outline-offset: 2px; }
.help-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 950; width: 380px; max-width: 100vw;
  display: none; flex-direction: column; background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: -6px 0 18px rgba(16, 24, 40, .08);
}
.help-panel.open { display: flex; }
.help-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.help-guide { padding: 10px 14px; background: var(--brand-soft); border-bottom: 1px solid var(--line); }
.help-guide:empty { display: none; }
.help-guide-title { font-weight: 600; margin-bottom: 4px; }
.help-guide-body { color: var(--text-dim); font-size: 13px; }
.help-log { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.help-msg { max-width: 92%; padding: 9px 12px; border-radius: 10px; font-size: 13px; line-height: 1.55; word-break: keep-all; }
.help-msg.me { align-self: flex-end; background: var(--brand); color: #fff; }
.help-msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); }
.help-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.help-chip { border: 1px solid var(--line-strong); background: var(--surface); color: var(--brand-dark); border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.help-chip:hover { background: var(--brand-soft); }
.help-form { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.help-form .input { flex: 1; }
.help-foot { padding: 0 14px 10px; color: var(--text-mute); font-size: 11px; }
@media (max-width: 560px) { .help-panel { width: 100vw; } .help-fab { right: 12px; bottom: 12px; } }
