:root {
  --bg: #ffffff;
  --panel: #fafafa;
  --ink: #0a0a0a;
  --ink-2: #3d3d3d;
  --muted: #8a8a8a;
  --line: #e8e8e8;
  --line-2: #d6d6d6;
  --hover: #f3f3f3;
  --ok: #0a0a0a;
  --err: #b00020;
  --radius: 14px;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Geist', 'Inter', -apple-system, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.mono { font-family: var(--mono); letter-spacing: 0.02em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 20; height: 60px; display: flex; align-items: center; gap: 28px;
  padding: 0 24px; background: rgba(255,255,255,0.85); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: 0.02em; }
.mark { width: 26px; height: 26px; border-radius: 7px; background: var(--ink); display: grid; place-items: center; }
.mark i { display: block; width: 2px; height: 12px; background: #fff; margin: 0 1.5px; border-radius: 2px; }
.mark span { display: flex; align-items: center; }
.brand small { font-family: var(--mono); font-weight: 400; font-size: 11px; color: var(--muted); letter-spacing: 0.12em; }
.nav { display: flex; gap: 4px; }
.nav button {
  white-space: nowrap; border: 0; background: none; padding: 8px 12px; border-radius: 999px; cursor: pointer; color: var(--muted);
  font-size: 13px; transition: all .15s;
}
.nav button:hover { color: var(--ink); background: var(--hover); }
.nav button.on { color: #fff; background: var(--ink); }
.top .spacer { flex: 1; }
.pill-status { font-family: var(--mono); font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); display: inline-block; }
.dot.on { background: var(--ink); box-shadow: 0 0 0 3px rgba(0,0,0,0.08); }
.dot.live { animation: pulse 1.4s infinite; background: var(--ink); }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- layout ---------- */
.view { display: none; }
.view.on { display: block; }
.ads-layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 60px); }
.side { border-right: 1px solid var(--line); padding: 20px 12px; position: sticky; top: 60px; height: calc(100vh - 60px); overflow: auto; }
.side h6, .label { margin: 0 0 10px 10px; font: 500 10.5px var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.side .item {
  width: 100%; display: flex; justify-content: space-between; align-items: center; border: 0; background: none; cursor: pointer;
  padding: 9px 10px; border-radius: 10px; text-align: left; color: var(--ink-2);
}
.side .item:hover { background: var(--hover); }
.side .item.on { background: var(--ink); color: #fff; }
.side .item .n { font: 11px var(--mono); color: var(--muted); }
.side .item.on .n { color: #bbb; }
.side hr { border: 0; border-top: 1px solid var(--line); margin: 14px 8px; }
main.content { padding: 24px 28px 80px; min-width: 0; }
.page { padding: 28px; max-width: 1200px; margin: 0 auto; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.head p { margin: 6px 0 0; color: var(--muted); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 12.5px; color: var(--muted); }
.seg button.on { background: var(--ink); color: #fff; }
.input, select.input, textarea.input {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #fff; outline: none; transition: border .15s;
}
.input:focus { border-color: var(--ink); }
textarea.input { width: 100%; min-height: 84px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--ink); background: var(--ink); color: #fff;
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-weight: 500; font-size: 13px; text-decoration: none; transition: transform .1s, opacity .15s;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.98); }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--ink); opacity: 1; }
.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn.block { width: 100%; padding: 12px; }
.btn[disabled] { opacity: .35; cursor: not-allowed; }
.soon { font: 10px var(--mono); letter-spacing: .1em; padding: 2px 6px; border: 1px solid currentColor; border-radius: 4px; }

/* ---------- ad grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.card { cursor: pointer; border-radius: var(--radius); transition: transform .2s; }
.card:hover { transform: translateY(-3px); }
.card .thumb {
  position: relative; aspect-ratio: 4 / 5; border-radius: var(--radius); overflow: hidden; background: var(--panel); border: 1px solid var(--line);
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card:hover .thumb { border-color: var(--ink); }
.badge {
  position: absolute; top: 10px; left: 10px; font: 500 10px var(--mono); letter-spacing: .12em; padding: 4px 8px; border-radius: 999px;
  background: rgba(10,10,10,.82); color: #fff; backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.28);
}
.days { position: absolute; bottom: 10px; right: 10px; font: 11px var(--mono); padding: 4px 8px; border-radius: 999px; background: rgba(255,255,255,.9); }
.play { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity .2s; }
.play span { width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.92); display: grid; place-items: center; }
.card:hover .play { opacity: 1; }
.card .meta { padding: 10px 2px 0; }
.card .meta b { font-weight: 500; font-size: 13px; }
.card .meta p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty { padding: 80px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.skeleton .thumb { background: linear-gradient(90deg, #f4f4f4, #ececec, #f4f4f4); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }
.notice { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 12px 14px; margin-bottom: 18px; font-size: 13px; color: var(--ink-2); }
.notice.err { border-color: #f1c4cc; background: #fff6f7; color: var(--err); }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10,10,10,.25); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: #fff; z-index: 50; border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column;
}
.drawer.on { transform: none; }
.drawer .dh { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer .db { padding: 20px; overflow: auto; flex: 1; }
.x { border: 1px solid var(--line); background: #fff; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
.x:hover { border-color: var(--ink); }
.preview { border-radius: var(--radius); overflow: hidden; background: #000; border: 1px solid var(--line); margin-bottom: 18px; display: grid; place-items: center; }
.preview video, .preview img { width: 100%; max-height: 520px; object-fit: contain; display: block; background: #000; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 13px; margin-bottom: 18px; }
.kv dt { color: var(--muted); font: 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; padding-top: 2px; }
.kv dd { margin: 0; white-space: pre-wrap; line-height: 1.45; }
.box { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }

/* ---------- jobs ---------- */
.jobs { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.job { display: grid; grid-template-columns: 56px 1fr 220px auto; gap: 16px; align-items: center; padding: 14px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.job:first-child { border-top: 0; }
.job:hover { background: var(--panel); }
.job .jt { width: 56px; height: 70px; border-radius: 8px; overflow: hidden; background: var(--panel); border: 1px solid var(--line); }
.job .jt img { width: 100%; height: 100%; object-fit: cover; }
.job h4 { margin: 0 0 4px; font-weight: 500; font-size: 14px; }
.job .sub { font: 11.5px var(--mono); color: var(--muted); }
.bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--ink); transition: width .5s; }
.st { font: 500 10.5px var(--mono); letter-spacing: .12em; text-transform: uppercase; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--line-2); }
.st.done { background: var(--ink); color: #fff; border-color: var(--ink); }
.st.failed { color: var(--err); border-color: #f1c4cc; }
.st.running { border-color: var(--ink); }
.actions { display: flex; gap: 8px; justify-content: flex-end; }

/* script table */
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th { text-align: left; font: 500 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); }
.table td { vertical-align: top; padding: 10px 8px; border-bottom: 1px solid var(--line); line-height: 1.45; }
.table td.t { font-family: var(--mono); white-space: nowrap; color: var(--muted); }
.imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.imgs a { display: block; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.imgs img { width: 100%; display: block; }

/* settings */
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.check { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; }
.check b { font-weight: 500; display: block; margin-bottom: 3px; }
.check code { font: 11px var(--mono); color: var(--muted); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 18px;
  border-radius: 999px; font-size: 13px; opacity: 0; transition: all .25s; z-index: 60; pointer-events: none;
}
.toast.on { opacity: 1; transform: translateX(-50%); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(circle at 1px 1px, #e9e9e9 1px, transparent 0) 0 0 / 22px 22px; }
.login form { width: 340px; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.06); }
.login h1 { font-size: 22px; margin: 18px 0 4px; letter-spacing: -0.02em; }
.login p { margin: 0 0 22px; color: var(--muted); }
.login .input { width: 100%; margin-bottom: 12px; padding: 12px 14px; }

@media (max-width: 860px) {
  .ads-layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); display: flex; gap: 6px; overflow-x: auto; padding: 12px; }
  .side h6, .side hr { display: none; }
  .side .item { width: auto; white-space: nowrap; gap: 8px; flex: 0 0 auto; }
  #brands { display: contents; }
  main.content, .page { padding: 18px 16px 60px; }
  .top { gap: 12px; padding: 0 16px; overflow-x: auto; }
  .brand small, .pill-status { display: none; }
  .job { grid-template-columns: 48px 1fr; }
  .job .jp, .job .actions { grid-column: 2; justify-content: flex-start; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}
