:root {
  --bg: #0f1115; --card: #171a21; --line: #262b36; --text: #e6e8ee;
  --muted: #8b93a7; --accent: #4f8cff; --accent-2: #3b6fe0; --danger: #e5484d;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg); color: var(--text); }
.top { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 18px; }
.brand span { font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 14px; }
#userbox { display: flex; gap: 12px; align-items: center; }
main { max-width: 1180px; margin: 24px auto; padding: 0 16px; }
/* 좌측 메뉴 레이아웃 */
.layout { display: flex; gap: 20px; align-items: flex-start; }
.sidebar { width: 210px; flex: none; position: sticky; top: 16px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.side-title { font-size: 12px; color: var(--muted); margin: 10px 10px 4px; }
.side-item { display: block; padding: 9px 12px; border-radius: 8px; color: var(--text);
  text-decoration: none; font-size: 14px; }
.side-item:hover { background: #222733; }
.side-item.active { background: var(--accent); color: #fff; }
.content { flex: 1; min-width: 0; }
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; display: flex; flex-wrap: wrap; gap: 4px; }
  .side-title { width: 100%; margin: 4px 8px; }
}
/* 검색 필터 바 */
.filterbar { display: flex; gap: 8px; align-items: center; margin: 10px 0 4px; flex-wrap: wrap; }
.filterbar input[type=search] { flex: 1; min-width: 200px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: #0f1218; color: var(--text); font-size: 14px; }
.filterbar select { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: #0f1218; color: var(--text); font-size: 14px; }
mark { background: #5a4a10; color: #ffe08a; border-radius: 2px; padding: 0 1px; }
/* 상세/편집 */
.editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.banner { background: #3a2a12; border: 1px solid #7a5a1a; color: #f5c26b; padding: 10px 14px;
  border-radius: 8px; margin-bottom: 12px; font-size: 14px; line-height: 1.5; }
#ed-title { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--line);
  background: #0f1218; color: var(--text); margin-top: 4px; font-size: 15px; }
#ed-title:disabled, input:disabled { opacity: .55; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: #1c2029; }
.tag.lock { background: #7a5a1a; }
.tag.ok-tag { background: #1f6f45; }
.empty { padding: 20px 0; text-align: center; }
.kv { border-collapse: collapse; font-size: 14px; margin: 6px 0 10px; }
.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 18px 6px 0; }
.kv td { padding: 6px 0; }
.auth-like { max-width: 420px; }
.auth-like label { margin: 8px 0; }
/* 가상 모니터 미리보기 */
#preview { position: fixed; inset: 0; z-index: 1000; background: #0a0b0e; display: flex; flex-direction: column; }
.pv-toolbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: var(--card); font-size: 14px; flex-wrap: wrap; }
.pv-toolbar label { display: flex; align-items: center; gap: 6px; margin: 0; }
.pv-toolbar select { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); background: #0f1218; color: var(--text); }
.pv-toolbar #pv-close { margin-left: auto; }
.pv-grid { flex: 1; display: grid; gap: 14px; padding: 16px; align-content: center; overflow: auto; }
.pv-mon { position: relative; background: #000; overflow: hidden; border: 3px solid #2a2f3a; border-radius: 6px;
  box-shadow: 0 8px 30px rgba(0,0,0,.6); width: 100%; }
.pv-mon .layer { position: absolute; inset: 0; overflow: hidden; }
.pv-mon .layer.b { display: none; }
.pv-mon .layer img { display: block; }
.pv-mon .layer img.fit-fill { width: 100%; height: 100%; object-fit: fill; }
.pv-mon .layer img.fit-original { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: none; }
.pv-mon .wm { position: absolute; color: #9a9a9a; font-family: Arial, sans-serif; z-index: 3; pointer-events: none; }
.pv-mon .pv-label { position: absolute; right: 8px; bottom: 6px; font-size: 11px; color: rgba(255,255,255,.45); z-index: 3; }
.pv-foot { padding: 8px 16px; border-top: 1px solid var(--line); text-align: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px; margin-bottom: 18px; }
.card h2 { margin: 0 0 8px; font-size: 17px; }
.card h2 small { font-weight: 400; margin-left: 8px; font-size: 13px; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.auth { max-width: 440px; margin: 40px auto; }
.auth form { display: flex; flex-direction: column; gap: 10px; }
.auth h2 { margin: 0 0 6px; font-size: 18px; }
.links { display: flex; justify-content: center; gap: 10px; margin-top: 6px; font-size: 13px; }
.links .sep { color: var(--line); }
#reset-timer { color: var(--accent); font-size: 16px; }
#reset-timer.warn { color: var(--danger); }
.row { display: flex; gap: 8px; margin-top: 4px; }
.row input { flex: 1; margin-top: 0 !important; }
.row .btn { white-space: nowrap; padding: 8px 12px; font-size: 13px; }
.row .btn:disabled { opacity: .5; cursor: default; }
label { display: block; font-size: 14px; margin: 6px 0; }
label.check { display: flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; }
input[type=email], input[type=password], input[type=text], textarea { width: 100%; padding: 10px; border-radius: 8px;
  border: 1px solid var(--line); background: #0f1218; color: var(--text); margin-top: 4px;
  font-family: inherit; font-size: 14px; }
textarea { resize: vertical; }
input[type=number] { width: 80px; padding: 6px; border-radius: 6px;
  border: 1px solid var(--line); background: #0f1218; color: var(--text); }
input:disabled { opacity: .45; }
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }
.btn { display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: #222733; color: var(--text); cursor: pointer; font-size: 14px; text-decoration: none; }
.btn:hover { background: #2a3040; }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.big { padding: 14px 22px; font-size: 15px; }
.btn.disabled { opacity: .4; cursor: not-allowed; }
a { color: var(--accent); }
/* 이미지 그리드 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.tile { background: #0f1218; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tile img { width: 100%; height: 100px; object-fit: cover; display: block; background: #000; }
.tile-bar { display: flex; gap: 6px; align-items: center; padding: 6px 8px; font-size: 12px; }
.tile-bar .idx { background: var(--accent); color: #fff; border-radius: 4px; padding: 0 6px; }
.tile-bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.tile-actions { display: flex; gap: 4px; padding: 0 8px 8px; }
.tile-actions button { flex: 1; padding: 4px; border-radius: 6px; border: 1px solid var(--line);
  background: #1c2029; color: var(--text); cursor: pointer; font-size: 12px; }
.tile-actions button:disabled { opacity: .3; cursor: default; }
.tile-actions button.danger { color: var(--danger); }
/* 설정 */
.settings fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0 0 12px; }
.settings legend { padding: 0 6px; color: var(--muted); font-size: 13px; }
.settings .sub { margin: 4px 0 10px 24px; font-size: 14px; }
.actions { display: flex; align-items: center; gap: 14px; }
.dl { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
/* 헤더 드롭다운 메뉴 (관리자 설정) */
.brand a { color: inherit; text-decoration: none; }
.menu { position: relative; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); min-width: 160px; z-index: 20;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.dropdown a { display: block; padding: 8px 12px; border-radius: 6px; color: var(--text);
  text-decoration: none; font-size: 14px; }
.dropdown a:hover { background: #222733; }
/* 관리자 설정 페이지 */
.settings-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.settings-head h2 { margin: 0; font-size: 20px; }
.subnav { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.subtab { background: none; border: none; color: var(--muted); padding: 8px 14px; cursor: pointer;
  font-size: 15px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subtab.active { color: var(--text); border-bottom-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.grid2 label.tls { grid-column: 1 / -1; }
.smtp input[type=text], .smtp input[type=password], .smtp input[type=number] { width: 100%; padding: 10px;
  border-radius: 8px; border: 1px solid var(--line); background: #0f1218; color: var(--text); margin-top: 4px; font-size: 14px; }
.sep-line { border: none; border-top: 1px solid var(--line); margin: 18px 0 12px; }
#panel-smtp h3 { margin: 0 0 4px; font-size: 15px; }
#panel-smtp .row input { padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: #0f1218; color: var(--text); font-size: 14px; }
.ok { color: #3ddc84; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
/* 템플릿 관리 */
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }
.tpl { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: #0f1218; }
.tpl h3 { margin: 0 0 8px; font-size: 15px; }
.tpl-status { font-size: 13px; margin-bottom: 10px; line-height: 1.6; }
.tpl-status .ready { color: #3ddc84; font-weight: 600; }
.tpl-status .missing { color: #f5c26b; font-weight: 600; }
.tpl-actions { display: flex; gap: 8px; }
.progress { height: 6px; background: #1c2029; border-radius: 3px; margin-top: 10px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.howto h3 { font-size: 14px; margin: 12px 0 4px; }
.howto ol { margin: 4px 0 8px 18px; padding: 0; font-size: 14px; line-height: 1.7; }
.howto code { background: #0f1218; border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; font-size: 13px; }
@media (max-width: 640px) { .tpl-grid { grid-template-columns: 1fr; } }
/* 관리자 테이블 */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 500; }
.tbl .purpose { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .tag { background: var(--accent); color: #fff; border-radius: 4px; padding: 0 6px; font-size: 11px; margin-left: 6px; }
.tbl button { padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line);
  background: #1c2029; color: var(--text); cursor: pointer; font-size: 12px; margin-left: 4px; }
.tbl button.danger { color: var(--danger); }
/* 토스트 */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #2a3040; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.toast.err { background: var(--danger); }

/* ---- 관리자: 사용자 상세 모달 ---- */
.modal-bg { position: fixed; inset: 0; z-index: 900; background: rgba(0,0,0,.6); display: flex; align-items: center;
  justify-content: center; padding: 16px; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 12px; width: min(720px, 100%);
  max-height: 92vh; overflow: auto; padding: 18px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.um-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.um-grid .um-wide { grid-column: 1 / -1; }
.um-grid select { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: #0f1218; color: var(--text); }
.um-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.um-actions .spacer { flex: 1; }
.tbl.clickable tbody tr { cursor: pointer; }
.tbl.clickable tbody tr:hover { background: rgba(255,255,255,.04); }
.tbl tbody tr.inactive td { opacity: .55; }
.tag.off { background: #6b2b2b; }
@media (max-width: 640px) { .um-grid { grid-template-columns: 1fr; } }
