:root {
  --brand: #333D9D;
  --brand-dark: #162755;
  --brand-light: rgba(51, 61, 157, .08);
  --line: #e5e7f0;
  --text: #1f2430;
  --dim: #8a90a3;
  --danger: #c0392b;
  --ok: #1a7f4b;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Pretendard', 'Noto Sans KR', -apple-system, sans-serif; color: var(--text); background: #f5f6fa; }
.hidden { display: none !important; }
button { cursor: pointer; font: inherit; }

/* 버튼 */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 14px; font-size: .92rem; }
.btn:hover { background: #f0f1f7; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #2a3384; }
.btn.ghost { border-color: transparent; background: transparent; color: #555c70; }
.btn.ghost:hover { background: var(--brand-light); }
.btn.wide { width: 100%; padding: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 로그인 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 40px 36px; width: 340px; box-shadow: 0 10px 40px rgba(22, 39, 85, .08); }
.login-card h1 { margin: 0; font-size: 1.4rem; color: var(--brand-dark); }
.login-sub { margin: 4px 0 24px; color: var(--dim); font-size: .85rem; }
.login-card input { width: 100%; margin-bottom: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: .95rem; }
.error { color: var(--danger); font-size: .85rem; min-height: 1.2em; margin: 10px 0 0; }

/* 상단바 */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.brand { font-weight: 800; color: var(--brand); font-size: 1.1rem; }
.brand span { color: var(--brand-dark); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.menu-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.who { color: var(--dim); font-size: .88rem; }
.save-state { font-size: .85rem; color: var(--dim); }
.save-state.dirty { color: #b3720a; font-weight: 600; }

/* 툴바 */
.toolbar { display: flex; align-items: center; gap: 12px; padding: 14px 20px 0; }
.search { flex: 0 1 340px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: .92rem; }
.row-count { color: var(--dim); font-size: .88rem; flex: 1; }

/* 테이블 */
.table-wrap { margin: 14px 20px; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: auto; max-height: calc(100vh - 320px); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
thead th { position: sticky; top: 0; background: #fafbfe; border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; color: #555c70; font-weight: 600; white-space: nowrap; }
tbody td { border-bottom: 1px solid #f0f1f7; padding: 10px 12px; vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--brand-light); }
tbody tr.removed { opacity: .55; }
tbody tr.removed .q-text { text-decoration: line-through; }
tbody tr.new-row { background: #f2fbf5; }
.col-id { width: 60px; }
.col-cat { width: 150px; }
.col-flag { width: 64px; white-space: nowrap; }
.q-text { font-weight: 500; }
.q-sub { color: var(--dim); font-size: .82rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 640px; }
.badge { display: inline-block; font-size: .75rem; border-radius: 6px; padding: 2px 8px; font-weight: 600; }
.badge.on { background: var(--brand-light); color: var(--brand); }
.badge.pub { background: #e9f7ef; color: var(--ok); }
.badge.draft { background: #fdf3e3; color: #b3720a; }
.badge.del { background: #fdecea; color: var(--danger); }
.badge.seo { background: #eef7fd; color: #2471a3; }
.dim { color: var(--dim); }

/* 이력 */
.history { margin: 0 20px 40px; }
.history h2 { font-size: .95rem; color: #555c70; }
.history ul { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.history li { padding: 6px 0; border-bottom: 1px dashed var(--line); }

/* 드로어 */
.mask { position: fixed; inset: 0; background: rgba(22, 39, 85, .35); z-index: 30; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 96vw); background: #fff; z-index: 31; display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(22, 39, 85, .15); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 1.05rem; color: var(--brand-dark); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.drawer-body label { display: block; font-size: .85rem; font-weight: 600; color: #555c70; }
.drawer-body input, .drawer-body textarea, .drawer-body select { width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: .93rem; }
.drawer-body textarea { resize: vertical; line-height: 1.6; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--line); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.check-line { display: flex; align-items: center; gap: 8px; font-weight: 500 !important; padding: 8px 0; }
.check-line input { width: auto !important; margin: 0 !important; }
.danger-line { color: var(--danger); }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0; }
legend { font-size: .82rem; color: #555c70; font-weight: 600; padding: 0 6px; }
.cat-checks { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.cat-checks label { display: flex; align-items: center; gap: 6px; font-weight: 400; font-size: .9rem; }
.cat-checks input { width: auto; margin: 0; }
.req { color: var(--danger); }
.seo-head { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
.seo-head .seo-title { font-size: .85rem; font-weight: 700; color: var(--brand-dark); }
.hint { color: var(--dim); font-weight: 400; font-size: .8rem; }

/* 모달 */
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(760px, 94vw); max-height: 86vh; background: #fff; border-radius: 14px; z-index: 41; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(22, 39, 85, .25); }
#modal-mask { z-index: 40; }
.modal-head { padding: 16px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 1.05rem; color: var(--brand-dark); }
.modal-body { flex: 1; overflow-y: auto; padding: 16px 22px; font-size: .9rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); }
.plan-group h3 { font-size: .92rem; margin: 14px 0 6px; }
.plan-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.plan-item .pi-title { font-weight: 600; margin-bottom: 4px; }
.diff-field { margin: 3px 0; }
.diff-field .fname { display: inline-block; min-width: 90px; color: #555c70; font-weight: 600; }
.diff-from { color: var(--danger); text-decoration: line-through; word-break: break-all; }
.diff-to { color: var(--ok); word-break: break-all; }
.plan-errors { background: #fdecea; border-radius: 8px; padding: 10px 14px; color: var(--danger); }
.apply-progress { text-align: center; padding: 30px 0; color: var(--brand-dark); font-weight: 600; }

/* 토스트 */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--brand-dark); color: #fff; border-radius: 10px; padding: 12px 22px; font-size: .92rem; z-index: 60; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); }
.toast.err { background: var(--danger); }
