:root {
  --bg: #0b0d10;
  --panel: #14181d;
  --panel-2: #1b2027;
  --line: #262d36;
  --text: #e7ecf2;
  --muted: #8b97a6;
  --accent: #22d3a8;
  --accent-dim: #128f72;
  --danger: #ff5c72;
  --warn: #ffb547;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* ---------- layout ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { font-weight: 700; letter-spacing: .3px; margin-right: 8px; white-space: nowrap; }
.brand span { color: var(--accent); }

.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }

.tab {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  position: relative;
}
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.active { color: var(--text); background: var(--panel-2); }

.tab .badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 9px;
  background: var(--accent);
  color: #04120e;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

main { padding: 24px; max-width: 1180px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* ---------- master switch ---------- */
.switch-wrap { display: flex; align-items: center; gap: 10px; }

.switch { position: relative; width: 52px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0;
  background: #3a434f;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s;
}
.switch .slider::before {
  content: "";
  position: absolute;
  width: 22px; height: 22px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .18s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(24px); }
.switch input:disabled + .slider { opacity: .5; cursor: not-allowed; }

.switch-label { font-size: 14px; color: var(--muted); white-space: nowrap; }
.switch-label.on { color: var(--accent); font-weight: 600; }

/* ---------- cards & grid ---------- */
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.stat .n { font-size: 30px; font-weight: 700; line-height: 1.1; }
.stat .k { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat.warn .n { color: var(--warn); }
.stat.danger .n { color: var(--danger); }
.stat.good .n { color: var(--accent); }

h2 { font-size: 18px; margin: 28px 0 14px; }
h2:first-child { margin-top: 0; }
h3 { font-size: 15px; margin: 0 0 10px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- buttons ---------- */
button, .btn {
  font: inherit;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { border-color: #3a434f; }
button:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #04120e; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 13px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }

input[type=text], input[type=password], input[type=number], input[type=url],
select, textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; min-height: 74px; font-size: 13px; }

input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }

.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.check { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.check label { margin: 0; color: var(--text); font-size: 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* ---------- clip review ---------- */
.clip { display: flex; flex-direction: column; }
.clip video {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 460px;
  background: #000;
  border-radius: 10px;
  margin-bottom: 12px;
  object-fit: contain;
}
.clip .title { font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.clip .meta { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.clip textarea { margin-bottom: 10px; }

/* ---------- tables & lists ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }

.item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  gap: 14px;
  align-items: center;
}
.item .grow { flex: 1; min-width: 0; }
.item .name { font-weight: 600; }
.item .sub { color: var(--muted); font-size: 12px; margin-top: 3px; word-break: break-all; }

.thumb { width: 96px; height: 54px; border-radius: 6px; object-fit: cover; background: var(--panel-2); flex: none; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.pill.ok { color: var(--accent); border-color: rgba(34,211,168,.4); background: rgba(34,211,168,.1); }
.pill.no { color: var(--muted); }
.pill.warn { color: var(--warn); border-color: rgba(255,181,71,.4); background: rgba(255,181,71,.1); }
.pill.bad { color: var(--danger); border-color: rgba(255,92,114,.4); background: rgba(255,92,114,.1); }

/* ---------- log ---------- */
.log {
  background: #07090b;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  height: 460px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.65;
}
.log .line { display: flex; gap: 10px; }
.log .ts { color: #4c5865; flex: none; }
.log .msg { white-space: pre-wrap; word-break: break-word; }
.log .warning .msg { color: var(--warn); }
.log .error .msg { color: var(--danger); }

/* ---------- status strip ---------- */
.status-strip {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 14px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.running { background: var(--accent); animation: pulse 1.4s infinite; }
.dot.stopped { background: #556; }
.dot.idle { background: var(--accent); opacity: .55; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: 100%; max-width: 360px; }
.login h1 { font-size: 22px; margin: 0 0 6px; }
.login p { color: var(--muted); font-size: 14px; margin: 0 0 22px; }

/* ---------- misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty .big { font-size: 15px; color: var(--text); margin-bottom: 6px; }

.error-box {
  background: rgba(255,92,114,.1);
  border: 1px solid rgba(255,92,114,.4);
  color: #ffb3bf;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
.warn-box {
  background: rgba(255,181,71,.1);
  border: 1px solid rgba(255,181,71,.4);
  color: #ffd79a;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 11px 20px; border-radius: 10px; font-size: 14px;
  z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.toast.err { border-color: var(--danger); color: #ffb3bf; }

@media (max-width: 640px) {
  main { padding: 16px; }
  .topbar { padding: 12px 16px; gap: 10px; }
  .brand { font-size: 14px; }
  .tab { padding: 7px 10px; font-size: 13px; }
}

/* ---------- destination pickers ---------- */
.dest-list {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  min-height: 40px;
  align-items: center;
}
.dest {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.dest input { width: 14px; height: 14px; margin: 0; }
.dest.on { border-color: var(--accent); color: var(--accent); background: rgba(34,211,168,.1); }
.dest-empty { color: var(--muted); font-size: 13px; }

.platform-card { display: flex; flex-direction: column; gap: 10px; }
.platform-card .row { margin-top: auto; }
.plat-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; border: 1px solid var(--line); color: var(--muted);
}
.plat-badge.tiktok    { color: #25f4ee; border-color: rgba(37,244,238,.4); }
.plat-badge.youtube   { color: #ff4e45; border-color: rgba(255,78,69,.4); }
.plat-badge.instagram { color: #e1306c; border-color: rgba(225,48,108,.4); }
.plat-badge.facebook  { color: #4c8bf5; border-color: rgba(76,139,245,.4); }
