:root {
  --bg: #f6f5f2; --panel: #fff; --ink: #1b1a17; --mute: #77736a; --line: #e4e1d9; --soft: #efede7;
  --accent: #2f5d50; --accent-soft: #e3eee9; --win: #b4541a; --win-soft: #fbeadc; --bad: #a33; --new: #3b5bbd; --new-soft: #e6ebfa;
  --r: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 -apple-system, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", sans-serif; display: flex; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.side { width: 232px; flex: none; background: #201f1b; color: #e9e6df; display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { font-size: 17px; font-weight: 700; padding: 0 8px 18px; }
.brand small { display: block; font-size: 11px; font-weight: 400; color: #9c978b; margin-top: 2px; }
#nav { display: flex; flex-direction: column; gap: 4px; }
#nav a { display: block; padding: 10px 10px; border-radius: 8px; cursor: pointer; color: #cfcbc1; }
#nav a b { display: block; font-size: 14px; }
#nav a span { font-size: 11px; color: #8f8a7e; }
#nav a.subnav { margin-left: 14px; padding: 7px 10px; border-left: 2px solid #3d3a33; border-radius: 0 8px 8px 0; }
#nav a.subnav b { font-size: 13px; }
#nav a:hover { background: #2c2a25; }
#nav a.on { background: #34322c; color: #fff; }
.who { margin-top: auto; padding: 8px; font-size: 12px; }
.who label { color: #9c978b; display: block; margin-bottom: 4px; }
.who input { width: 100%; background: #2c2a25; border: 1px solid #3d3a33; border-radius: 6px; padding: 6px 8px; color: #fff; }
.conn { margin-top: 12px; display: grid; gap: 3px; color: #9c978b; font-size: 11px; }
.conn i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: #6fbf8f; }
.conn i.off { background: #c9735b; }

main { flex: 1; min-width: 0; padding: 26px 30px 60px; }
h1 { font-size: 22px; margin: 0 0 4px; }
.sub { color: var(--mute); margin: 0 0 18px; font-size: 13px; }
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.bar .sp { flex: 1; }
.seg { display: inline-flex; background: var(--soft); border-radius: 8px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--mute); }
.seg button.on { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.btn { border: 1px solid var(--line); background: var(--panel); padding: 7px 12px; border-radius: 8px; cursor: pointer; }
.btn:hover { border-color: #c9c5ba; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--mute); }
.field input, .field select { width: 84px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); }
input[type=text], input[type=url], textarea, select.full { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
textarea { resize: vertical; min-height: 84px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.pad { padding: 16px; }
.empty { color: var(--mute); padding: 40px; text-align: center; }
.note { font-size: 12px; color: var(--mute); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 20px; background: var(--soft); color: var(--mute); white-space: nowrap; }
.tag.win { background: var(--win-soft); color: var(--win); font-weight: 700; }
.tag.new { background: var(--new-soft); color: var(--new); font-weight: 600; }
.tag.ok { background: var(--accent-soft); color: var(--accent); }

/* 위닝 */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.kpi span { font-size: 12px; color: var(--mute); display: block; }
.kpi b { font-size: 20px; font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; }
th { text-align: right; font-size: 12px; color: var(--mute); font-weight: 500; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
th:nth-child(-n+2) { text-align: left; cursor: default; }
td { padding: 8px 10px; border-bottom: 1px solid var(--soft); text-align: right; font-variant-numeric: tabular-nums; vertical-align: middle; }
td:nth-child(-n+2) { text-align: left; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #faf9f6; }
tr.winrow td:first-child { box-shadow: inset 3px 0 0 var(--win); }
.thumb { width: 40px; height: 62px; border-radius: 5px; object-fit: cover; background: var(--soft); display: block; }
.daterange { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--mute); padding: 3px 6px; border-radius: 8px; }
.daterange.on { background: var(--accent-soft); }
.daterange input { padding: 5px 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); }
th small { font-weight: 400; }
.panel:has(> table) { overflow-x: auto; }
.adname { font-weight: 600; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adsub { font-size: 11px; color: var(--mute); display: flex; gap: 5px; flex-wrap: wrap; margin-top: 2px; }
.good { color: #d0271d; font-weight: 700; }
.dim { color: #b0aca2; }

/* 모달 */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal-bg { position: absolute; inset: 0; background: rgba(20,19,16,.55); }
.modal-box { position: relative; background: var(--panel); border-radius: 14px; width: min(1180px, 94vw); max-height: 92vh; overflow: auto; padding: 22px; }
.modal-box.narrow { width: min(460px, 94vw); padding: 12px; background: #000; }
.modal-box.narrow video { width: 100%; max-height: 86vh; display: block; border-radius: 8px; }
.x { position: absolute; top: 12px; right: 14px; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--mute); }
.detail { display: grid; grid-template-columns: 330px minmax(0, 1fr) minmax(0, 1fr); gap: 18px; margin-top: 14px; }
.detail h3 { font-size: 13px; margin: 0 0 8px; color: var(--mute); font-weight: 600; }
.frame { width: 100%; aspect-ratio: 9/16; border: 0; border-radius: 10px; background: #111; }
.script { white-space: pre-wrap; background: #faf9f6; border: 1px solid var(--line); border-radius: 8px; padding: 12px; max-height: 480px; overflow: auto; font-size: 13.5px; line-height: 1.7; }
.filelist { display: grid; gap: 6px; margin-top: 8px; }
.file { display: flex; gap: 8px; align-items: center; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; cursor: pointer; }
.file.on { border-color: var(--accent); background: var(--accent-soft); }
.file b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

/* 광고 라이브러리 */
.shop { margin-bottom: 6px; }
.shop-h[data-toggle] { cursor: pointer; border-bottom: 0; padding: 9px 14px; }
.shop.open { margin: 10px 0 14px; }
.shop.open .shop-h { border-bottom: 1px solid var(--line); }
.shop-h:hover { background: #faf9f6; }
.chev { color: var(--mute); width: 14px; }
.shop-h { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.shop-h b { font-size: 16px; }
.verdict { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.verdict button { border: 0; background: var(--panel); padding: 5px 11px; cursor: pointer; font-size: 12px; color: var(--mute); }
.verdict button + button { border-left: 1px solid var(--line); }
.verdict button.good.on { background: var(--accent); color: #fff; }
.verdict button.bad.on { background: #8b3a3a; color: #fff; }
.shop.isbad { opacity: .55; }
.rows { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.rowblock { padding: 14px 16px; }
.rowblock + .rowblock { border-left: 1px solid var(--line); }
.rowblock h4 { margin: 0 0 10px; font-size: 13px; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cards.wide { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.ad { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--panel); display: flex; flex-direction: column; }
.ad .media { position: relative; aspect-ratio: 4/5; background: #1c1b18 center/cover no-repeat; cursor: pointer; }
.ad .media .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 30px; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.ad .media .rank { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.72); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 20px; }
.ad .media .days { position: absolute; right: 6px; top: 6px; }
.ad .body { padding: 8px 9px; font-size: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.ad .txt { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: #4a473f; min-height: 3.9em; }
.ad .acts { display: flex; gap: 6px; margin-top: auto; }
.ad .shopname { font-weight: 700; }

/* 대본 */
.gen { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 18px; align-items: start; }
.styles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.stylecard { border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; cursor: pointer; background: var(--panel); text-align: left; }
.stylecard b { display: block; }
.stylecard span { font-size: 11px; color: var(--mute); }
.stylecard.on { border-color: var(--accent); background: var(--accent-soft); }
.stylecard:disabled { opacity: .5; cursor: default; }
.lbl { font-size: 12px; color: var(--mute); margin: 12px 0 5px; display: block; }
.out { white-space: pre-wrap; line-height: 1.75; font-size: 14px; min-height: 300px; }
.hist { margin-top: 14px; display: grid; gap: 6px; }
.hist div { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 12px; background: var(--panel); }
.warn { background: #fdf3e3; border: 1px solid #efd9b3; color: #7a5516; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }

/* 레퍼런스 */
.addref { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.6fr) 150px auto; gap: 8px; margin-bottom: 18px; }
.refs { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.ref video, .ref .ph { width: 100%; aspect-ratio: 9/12; background: #1c1b18 center/cover no-repeat; display: block; object-fit: contain; }
.ref .ph { display: grid; place-items: center; color: #cfcbc1; font-size: 13px; text-align: center; padding: 16px; }
.ref .meta { padding: 10px 12px; display: grid; gap: 8px; }
.ref .ttl { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmt { background: #faf9f6; border-radius: 7px; padding: 7px 9px; font-size: 13px; white-space: pre-wrap; }
.cmt small { display: block; color: var(--mute); font-size: 11px; }
.cmtform { display: flex; gap: 6px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #201f1b; color: #fff; padding: 10px 16px; border-radius: 9px; z-index: 30; font-size: 13px; }
.toast[hidden] { display: none; }

@media (max-width: 1100px) {
  .rows, .gen, .detail { grid-template-columns: 1fr; }
  .rowblock + .rowblock { border-left: 0; border-top: 1px solid var(--line); }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .addref { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; padding: 12px; }
  #nav { flex-direction: row; overflow-x: auto; }
  #nav a span, .conn { display: none; }
  .who { margin-top: 8px; }
  main { padding: 16px; }
  .panel { overflow-x: auto; }
}

td.sub1d { color: #6a665d; background: #faf9f6; }
