:root {
  --bg: #ffffff;
  --soft: #f6f8fc;
  --soft-2: #f1f4f9;
  --line: #e7ebf2;
  --line-strong: #d5dbe6;
  --text: #172033;
  --muted: #667085;
  --faint: #98a2b3;
  --brand: #2463eb;
  --brand-dark: #1b4fc4;
  --brand-soft: #edf3ff;
  --amber: #b45309;
  --amber-soft: #fff4e0;
  --green: #067647;
  --green-soft: #e8f7ef;
  --red: #c0392b;
  --red-soft: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .07);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR",
    "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }
h1, h2, h3 { margin: 0; line-height: 1.3; letter-spacing: -.01em; }
p { margin: 0; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- 상단 바 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 750; font-size: 17px; letter-spacing: -.02em; }
.brand:hover { color: var(--text); }
.yt-mark { display: block; flex: none; width: 30px; height: 21px; }
.brand-text { white-space: nowrap; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.nav a, .nav button.link {
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
.nav a:hover, .nav button.link:hover { background: var(--soft-2); color: var(--text); }
.nav a.on { color: var(--brand); background: var(--brand-soft); }
.nav .who { color: var(--faint); font-size: 13px; padding: 0 8px; }
.nav form { margin: 0; }
.dot {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  font-weight: 700;
}

main { padding: 32px 0 64px; }

/* ---------- 버튼 · 폼 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--soft); color: var(--text); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(36, 99, 235, .3); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-danger { color: var(--red); border-color: #f1c4be; background: #fff; }
.btn-danger:hover { background: var(--red-soft); color: var(--red); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.inline { display: inline; margin: 0; }

label { display: block; font-size: 13px; font-weight: 650; margin-bottom: 6px; color: var(--text); }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: #fff;
  color: var(--text);
  font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 200px; line-height: 1.7; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(36, 99, 235, .12); }
.field { margin-bottom: 16px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.two-one { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* ---------- 카드 · 알림 ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card + .card { margin-top: 20px; }
.card h2 { font-size: 17px; margin-bottom: 4px; }
.card .lead { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.flash.ok { background: var(--green-soft); border-color: #b7e4cd; color: var(--green); }
.flash.warn { background: var(--amber-soft); border-color: #f2cf8d; color: #8a5a00; }
.opts { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: -4px 0 18px; }
.opts .check { min-height: 30px; font-size: 13.5px; color: var(--muted); }
.flash.error { background: var(--red-soft); border-color: #f4c7c1; color: var(--red); }

/* ---------- 인증 화면 ---------- */
.auth { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 32px 20px 64px; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 36px 32px; box-shadow: var(--shadow); }
.auth-card .brand { justify-content: center; width: 100%; margin-bottom: 8px; }
.auth-card h1 { font-size: 22px; text-align: center; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); text-align: center; font-size: 14px; margin-bottom: 26px; }
.auth-card .btn { width: 100%; min-height: 46px; }
.auth-foot { text-align: center; margin-top: 20px; font-size: 14px; color: var(--muted); }

/* ---------- 목록 화면 ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; letter-spacing: -.02em; }
.page-head p { color: var(--muted); margin-top: 6px; font-size: 14px; max-width: 640px; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.tile { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; background: #fff; }
.tile .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.tile .v { font-size: 22px; font-weight: 750; margin-top: 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile .v.small { font-size: 16px; line-height: 1.5; padding-top: 6px; }
.tile .s { font-size: 12px; color: var(--faint); margin-top: 2px; }
.tile.accent { background: var(--amber-soft); border-color: #f6dcaa; }
.tile.accent .v { color: var(--amber); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.toolbar .group { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.seg { display: inline-flex; background: var(--soft-2); border-radius: 999px; padding: 4px; }
.seg a { padding: 7px 15px; border-radius: 999px; color: var(--muted); font-size: 14px; font-weight: 650; white-space: nowrap; }
.seg a:hover { color: var(--text); }
.seg a.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(16, 24, 40, .14); }
.seg .c { color: var(--faint); font-weight: 600; margin-left: 4px; font-size: 12px; }
.seg.sm a { padding: 5px 12px; font-size: 13px; }
.kw { display: inline-block; padding: 3px 11px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; min-height: 44px; margin: 0; }
.check input { width: 18px; height: 18px; }
.fmt-form { display: inline-flex; gap: 6px; align-items: center; }
.fmt-form select { min-height: 34px; padding: 4px 8px; font-size: 13px; width: auto; border-radius: 9px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); font-size: 14px; font-weight: 650; background: #fff; }
.chip:hover { background: var(--soft); color: var(--text); }
.chip.gold.on { background: #fff3c4; border-color: #f0cf5d; color: #8a5a00; }
.chip .c { font-weight: 600; opacity: .7; }
.chip.on { background: var(--amber-soft); border-color: #f2cf8d; color: var(--amber); }

.list { display: grid; gap: 12px; }
.video {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr) 250px;
  gap: 20px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  transition: box-shadow .15s, border-color .15s;
}
.video:hover { box-shadow: var(--shadow); border-color: var(--line-strong); }
.thumb { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--soft-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dur { position: absolute; right: 8px; bottom: 8px; padding: 1px 7px; border-radius: 6px; background: rgba(0, 0, 0, .8); color: #fff; font-size: 11.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tag { position: absolute; left: 8px; top: 8px; padding: 2px 8px; border-radius: 7px; background: rgba(23, 32, 51, .78); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.v-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--text); font-weight: 650; font-size: 15px; line-height: 1.45; }
.v-title:hover { color: var(--brand); }
.v-channel { color: var(--muted); font-size: 13px; margin-top: 3px; }
.v-body { min-width: 0; }
.metrics { display: flex; flex-wrap: wrap; gap: 8px 26px; margin: 12px 0 0; }
.metric { margin: 0; }
.metric dt { font-size: 11.5px; color: var(--faint); font-weight: 600; }
.metric dd { margin: 1px 0 0; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.v-state { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.v-graph { min-width: 0; }
.v-graph .cap { font-size: 11.5px; color: var(--faint); margin-bottom: 2px; }
.graph { display: block; width: 100%; height: auto; }
.nodata { display: grid; place-items: center; height: 80px; border-radius: 10px; background: var(--soft); color: var(--faint); font-size: 13px; }

.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--brand-soft); color: var(--brand); }
.badge.gray { background: var(--soft-2); color: var(--muted); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.rose { background: #fde8ef; color: #be185d; }
.badge.teal { background: #def5f2; color: #0f766e; }
.badge.gold { background: #fff3c4; color: #8a5a00; }
.badge.green { background: var(--green-soft); color: var(--green); }

.empty { text-align: center; padding: 64px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 6px; }

.legend { margin-top: 28px; padding: 18px 20px; background: var(--soft); border-radius: var(--radius); color: var(--muted); font-size: 13px; line-height: 1.8; }
.legend b { color: var(--text); }

.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 24px; font-size: 14px; color: var(--muted); }
.job { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 관리자 ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 10px 16px; color: var(--muted); font-weight: 650; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 20px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); background: var(--soft); padding: 11px 14px; white-space: nowrap; }
td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
td.wide { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.errbox { text-align: center; padding: 80px 20px; }
.errbox .code { font-size: 64px; font-weight: 800; color: var(--brand); letter-spacing: -.04em; line-height: 1; }
.errbox h1 { font-size: 20px; margin: 14px 0 8px; }

/* ---------- 반응형 ---------- */
@media (max-width: 860px) {
  .video { grid-template-columns: 148px minmax(0, 1fr); }
  .v-graph { grid-column: 1 / -1; }
  .form-grid, .form-grid.two, .form-grid.two-one { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  main { padding: 22px 0 48px; }
  .topbar-in { height: auto; min-height: 56px; padding-top: 8px; padding-bottom: 8px; flex-wrap: wrap; }
  .nav .who { display: none; }
  .brand { font-size: 15px; gap: 8px; }
  .yt-mark { width: 27px; height: 19px; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tiles .tile:last-child { grid-column: 1 / -1; }
  .page-head h1 { font-size: 22px; }
  .video { grid-template-columns: 112px minmax(0, 1fr); gap: 10px 12px; padding: 12px; align-items: start; }
  .v-title { font-size: 14px; }
  .metrics { gap: 6px 16px; margin-top: 8px; }
  .metric dd { font-size: 14px; }
  .v-state { margin-top: 8px; }
  .tag { left: 5px; top: 5px; padding: 1px 6px; font-size: 10px; }
  .v-graph .cap { display: none; }
  .v-graph .graph { max-width: 300px; }
  .nodata { height: 56px; }
  .card { padding: 18px; }
  .auth-card { padding: 28px 22px; }
  .seg a { padding: 7px 11px; }
}
