:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e3e5e9;
  --text: #16181d;
  --text-2: #4b5160;
  --muted: #7a8090;
  --brand: #d4141c;           /* JW 레드 */
  --brand-ink: #ffffff;
  --accent: #2a78d6;
  --accent-soft: #e6f0fc;
  --good: #0e7a3c;  --good-soft: #e3f5ea;
  --warn: #9a6200;  --warn-soft: #fdf1d8;
  --bad: #b42318;   --bad-soft: #fde8e6;
  --info: #1c5cab;  --info-soft: #e6f0fc;
  --action: #6250d6; --action-soft: #eeebfc;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --grid: #eceef1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 4px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121315; --surface: #1b1c1f; --surface-2: #222327; --border: #33353a;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #8d8f96;
    --accent: #3987e5; --accent-soft: #1d2a3b;
    --good: #5cc98a; --good-soft: #17301f; --warn: #e2b04a; --warn-soft: #33290f;
    --bad: #f07a70; --bad-soft: #3a1b18; --info: #86b6ef; --info-soft: #1d2a3b;
    --action: #9085e9; --action-soft: #2a2645;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --grid: #2a2c30;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 17px/1.55 'Pretendard Variable', Pretendard, 'Malgun Gothic', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 18px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }
.boot, .loading, .empty { padding: 58px; text-align: center; color: var(--muted); }

/* ── 레이아웃 ── */
.shell { display: grid; grid-template-columns: 278px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 22px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 19px; color: var(--text); padding: 5px 10px 22px; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); font-size: 14px; letter-spacing: .5px; }
.brand.big { font-size: 24px; justify-content: center; padding-bottom: 7px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a { display: block; padding: 10px 14px; border-radius: 10px; color: var(--text-2); font-weight: 500; }
.sidebar nav a:hover { background: var(--surface-2); text-decoration: none; }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-group { margin-top: 12px; }
.nav-group-title { padding: 7px 14px; font-size: 14px; color: var(--muted); font-weight: 600; }
.nav-group a { padding-left: 24px !important; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.me { color: var(--text); font-weight: 600; }
.me small { color: var(--muted); font-weight: 400; margin-left: 5px; }
main { padding: 34px 38px 77px; min-width: 0; max-width: 1680px; }
.nav-toggle { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 19px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin: 5px 0 0; color: var(--muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ── 카드·그리드 ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card + .card { margin-top: 19px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 17px; gap: 10px; flex-wrap: wrap; }
.card-head .muted { font-size: 14px; }
.grid { display: grid; gap: 19px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 19px; }
.grid + .grid, .grid + .card, .card + .grid { margin-top: 19px; }
.span-2 { grid-column: span 2; }
.kpi-tile .label { color: var(--muted); font-size: 16px; }
.kpi-tile .value { font-size: 34px; font-weight: 700; margin-top: 5px; font-variant-numeric: tabular-nums; }
.kpi-tile .value small { font-size: 17px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi-tile .sub { font-size: 14px; color: var(--muted); margin-top: 2px; }
.chart-box { position: relative; height: 336px; }
.chart-box.tall { height: 432px; }

/* ── 폼 ── */
label { display: flex; flex-direction: column; gap: 7px; font-weight: 600; font-size: 16px; color: var(--text-2); }
label:not(.check) > input:not([type=checkbox]):not([type=radio]), label:not(.check) > select, label:not(.check) > textarea { width: 100%; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 144px; resize: vertical; line-height: 1.6; }
input[type=checkbox] { width: 19px; height: 19px; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px 19px; }
.form-grid .full { grid-column: 1 / -1; }
.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 17px; align-items: center; }
.filters input[type=search] { width: 264px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; padding: 10px 17px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 12px; font-size: 16px; }
.btn.block { width: 100%; }
.icon-btn { border: 0; background: none; cursor: pointer; font-size: 19px; color: var(--muted); padding: 5px; }

/* ── 표 ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 14px; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
tbody tr:hover { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
td.nowrap, th.nowrap { white-space: nowrap; }
td.right, th.right { text-align: right; }
td.center, th.center { text-align: center; }
.title-cell { font-weight: 600; color: var(--text); }
.ellipsis { max-width: 504px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; justify-content: center; align-items: center; gap: 7px; margin-top: 17px; }
.overdue { color: var(--bad); font-weight: 600; }

/* ── 배지 ── */
.badge { display: inline-block; padding: 2px 11px; border-radius: 1199px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.tone-neutral { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-warn { background: var(--warn-soft); color: var(--warn); }
.tone-action { background: var(--action-soft); color: var(--action); }
.tone-good { background: var(--good-soft); color: var(--good); }
.tone-bad { background: var(--bad-soft); color: var(--bad); }
.tone-muted { background: var(--surface-2); color: var(--muted); }
.tag { display: inline-block; padding: 1px 10px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; color: var(--text-2); }

/* ── 요청 상세 ── */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 384px; gap: 19px; align-items: start; }
.post-body { white-space: normal; word-break: break-word; line-height: 1.75; }
.meta-list { display: grid; grid-template-columns: 115px 1fr; gap: 10px 12px; margin: 0; }
.meta-list dt { color: var(--muted); font-size: 16px; }
.meta-list dd { margin: 0; font-weight: 500; word-break: break-all; }
.files { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.file-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 16px; background: var(--surface-2); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(192px, 1fr)); gap: 10px; margin-top: 12px; }
.thumbs img { width: 100%; border: 1px solid var(--border); border-radius: 7px; display: block; }
.thumbs figure { margin: 0; }
.thumbs figcaption { font-size: 13px; color: var(--muted); margin-top: 2px; word-break: break-all; }

.comments { display: flex; flex-direction: column; gap: 14px; }
.comment { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 17px; background: var(--surface); }
.comment.k-agent { background: var(--accent-soft); border-color: transparent; }
.comment.k-feedback { border-left: 4px solid var(--warn); }
.comment.k-approve, .comment.k-final { border-left: 4px solid var(--good); }
.comment.k-status { background: var(--surface-2); }
.comment-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; font-size: 16px; }
.comment-head b { color: var(--text); }
.comment-body { word-break: break-word; line-height: 1.7; }
.comment-form textarea { min-height: 108px; }
.cta-box { border: 1px solid var(--action); background: var(--action-soft); border-radius: var(--radius); padding: 19px; margin-bottom: 19px; }
.cta-box h3 { color: var(--action); margin-bottom: 7px; }
.url-list { margin: 10px 0 0; padding-left: 22px; }
.url-list li { word-break: break-all; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; font-size: 16px; }
.timeline li::before { content: ''; position: absolute; left: 5px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ''; position: absolute; left: 8px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }

/* ── 개요 ── */
.flow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; counter-reset: step; }
.flow-step { position: relative; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 17px 14px; }
.flow-step::before { counter-increment: step; content: counter(step); display: inline-grid; place-items: center; width: 29px; height: 29px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.flow-step h4 { font-size: 17px; margin-bottom: 5px; }
.flow-step p { margin: 0; font-size: 14px; color: var(--text-2); }
.flow-step .who { margin-top: 10px; }
.status-table td:first-child { white-space: nowrap; }

/* ── 권한 표 ── */
.perm-table th, .perm-table td { text-align: center; padding: 10px; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }

/* ── 모달·토스트 ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 16, .45); display: grid; place-items: center; z-index: 50; padding: 19px; }
.modal { background: var(--surface); border-radius: 14px; width: min(672px, 100%); max-height: calc(100vh - 38px); display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(0, 0, 0, .25); }
.modal.wide { width: min(1032px, 100%); }
.modal header, .modal footer { display: flex; align-items: center; justify-content: space-between; padding: 17px 22px; }
.modal header { border-bottom: 1px solid var(--border); }
.modal footer { border-top: 1px solid var(--border); justify-content: flex-end; gap: 10px; }
.modal-body { padding: 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 17px; }
.toast { position: fixed; left: 50%; bottom: 29px; transform: translate(-50%, 24px); opacity: 0; transition: .25s; padding: 12px 22px; border-radius: 10px; font-weight: 600; z-index: 60; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── 로그인 ── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 19px; }
.login { width: min(456px, 100%); display: flex; flex-direction: column; gap: 17px; padding: 38px 34px; }
.login p { margin: 0; text-align: center; }
.error { color: var(--bad); font-size: 16px; text-align: center; }
pre.log { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 14px; overflow-x: auto; white-space: pre-wrap; max-height: 384px; margin: 10px 0 0; }

/* ── 반응형 ── */
@media (max-width: 1320px) {
  .grid.kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 984px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 40; left: 0; width: 312px; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 48px rgba(0, 0, 0, .3); }
  .nav-toggle { display: block; position: fixed; top: 14px; right: 14px; z-index: 41; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; width: 48px; height: 48px; font-size: 22px; cursor: pointer; color: var(--text); }
  main { padding: 77px 19px 58px; }
  .grid.cols-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .filters input[type=search] { width: 100%; }
  .ellipsis { max-width: 264px; }
}
